mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-29 06:10:09 +08:00
Remove gaps between RELX sections update
Update file_offset as well
This commit is contained in:
parent
64d5db7635
commit
4d254312be
11
tccelf.c
11
tccelf.c
@ -2247,6 +2247,7 @@ static int final_sections_reloc(TCCState *s1)
|
|||||||
static void update_reloc_sections(TCCState *s1, struct dyn_inf *dyninf)
|
static void update_reloc_sections(TCCState *s1, struct dyn_inf *dyninf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
unsigned long file_offset = 0;
|
||||||
Section *s;
|
Section *s;
|
||||||
Section *relocplt = s1->got ? s1->got->relocplt : NULL;
|
Section *relocplt = s1->got ? s1->got->relocplt : NULL;
|
||||||
|
|
||||||
@ -2255,11 +2256,15 @@ static void update_reloc_sections(TCCState *s1, struct dyn_inf *dyninf)
|
|||||||
|
|
||||||
for(i = 1; i < s1->nb_sections; i++) {
|
for(i = 1; i < s1->nb_sections; i++) {
|
||||||
s = s1->sections[i];
|
s = s1->sections[i];
|
||||||
if (s->sh_type == SHT_RELX && s != relocplt) {
|
if (s->sh_type == SHT_RELX && s->sh_size && s != relocplt) {
|
||||||
if (dyninf->rel_size == 0)
|
if (dyninf->rel_size == 0) {
|
||||||
dyninf->rel_addr = s->sh_addr;
|
dyninf->rel_addr = s->sh_addr;
|
||||||
else
|
file_offset = s->sh_offset;
|
||||||
|
}
|
||||||
|
else {
|
||||||
s->sh_addr = dyninf->rel_addr + dyninf->rel_size;
|
s->sh_addr = dyninf->rel_addr + dyninf->rel_size;
|
||||||
|
s->sh_offset = file_offset + dyninf->rel_size;
|
||||||
|
}
|
||||||
dyninf->rel_size += s->sh_size;
|
dyninf->rel_size += s->sh_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user