diff options
| author | grischka <grischka> | 2008-04-27 18:49:31 +0000 |
|---|---|---|
| committer | grischka <grischka> | 2008-04-27 18:49:31 +0000 |
| commit | 5247bbc2f040a9b6e40fa3d82892d0a794fe7cdc (patch) | |
| tree | 4c144cfbaefb8ce2f0a94ba5d1ed8ab650a372b8 | |
| parent | 0d598aca087e46ea67f97dda50df3eed522d5e7a (diff) | |
| download | tinycc-5247bbc2f040a9b6e40fa3d82892d0a794fe7cdc.tar.gz tinycc-5247bbc2f040a9b6e40fa3d82892d0a794fe7cdc.tar.bz2 | |
fix stabstr with linked objects
| -rw-r--r-- | tcc.c | 2 | ||||
| -rw-r--r-- | tccelf.c | 32 |
2 files changed, 33 insertions, 1 deletions
@@ -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; } @@ -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++) { |
