mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-28 08:10:25 +08:00
fix stabstr with linked objects
This commit is contained in:
parent
0d598aca08
commit
5247bbc2f0
2
tcc.c
2
tcc.c
@ -9148,6 +9148,8 @@ void put_func_debug(Sym *sym)
|
||||
funcname, sym->type.t & VT_STATIC ? 'f' : 'F');
|
||||
put_stabs_r(buf, N_FUN, 0, file->line_num, 0,
|
||||
cur_text_section, sym->c);
|
||||
/* //gr gdb wants a line at the function */
|
||||
put_stabn(N_SLINE, 0, file->line_num, 0);
|
||||
last_ind = 0;
|
||||
last_line_num = 0;
|
||||
}
|
||||
|
32
tccelf.c
32
tccelf.c
@ -1821,6 +1821,11 @@ static int tcc_load_object_file(TCCState *s1,
|
||||
Elf32_Rel *rel, *rel_end;
|
||||
Section *s;
|
||||
|
||||
int stab_index;
|
||||
int stabstr_index;
|
||||
|
||||
stab_index = stabstr_index = 0;
|
||||
|
||||
if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
|
||||
goto fail1;
|
||||
if (ehdr.e_ident[0] != ELFMAG0 ||
|
||||
@ -1885,7 +1890,9 @@ static int tcc_load_object_file(TCCState *s1,
|
||||
#ifdef TCC_ARM_EABI
|
||||
sh->sh_type != SHT_ARM_EXIDX &&
|
||||
#endif
|
||||
sh->sh_type != SHT_NOBITS)
|
||||
sh->sh_type != SHT_NOBITS &&
|
||||
strcmp(sh_name, ".stabstr")
|
||||
)
|
||||
continue;
|
||||
if (sh->sh_addralign < 1)
|
||||
sh->sh_addralign = 1;
|
||||
@ -1921,11 +1928,22 @@ static int tcc_load_object_file(TCCState *s1,
|
||||
|
||||
/* align start of section */
|
||||
offset = s->data_offset;
|
||||
|
||||
if (0 == strcmp(sh_name, ".stab")) {
|
||||
stab_index = i;
|
||||
goto no_align;
|
||||
}
|
||||
if (0 == strcmp(sh_name, ".stabstr")) {
|
||||
stabstr_index = i;
|
||||
goto no_align;
|
||||
}
|
||||
|
||||
size = sh->sh_addralign - 1;
|
||||
offset = (offset + size) & ~size;
|
||||
if (sh->sh_addralign > s->sh_addralign)
|
||||
s->sh_addralign = sh->sh_addralign;
|
||||
s->data_offset = offset;
|
||||
no_align:
|
||||
sm_table[i].offset = offset;
|
||||
sm_table[i].s = s;
|
||||
/* concatenate sections */
|
||||
@ -1941,6 +1959,18 @@ static int tcc_load_object_file(TCCState *s1,
|
||||
next: ;
|
||||
}
|
||||
|
||||
/* //gr relocate stab strings */
|
||||
if (stab_index && stabstr_index) {
|
||||
Stab_Sym *a, *b;
|
||||
unsigned o;
|
||||
s = sm_table[stab_index].s;
|
||||
a = (Stab_Sym *)(s->data + sm_table[stab_index].offset);
|
||||
b = (Stab_Sym *)(s->data + s->data_offset);
|
||||
o = sm_table[stabstr_index].offset;
|
||||
while (a < b)
|
||||
a->n_strx += o, a++;
|
||||
}
|
||||
|
||||
/* second short pass to update sh_link and sh_info fields of new
|
||||
sections */
|
||||
for(i = 1; i < ehdr.e_shnum; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user