History

fix stabstr with linked objects

grischka committed 18 years ago

Commit 5247bbc1 parent 0d598ac2 files · +33 −1Browse files

Unified · Split

2 files
  1. tcc.c +2 −0
  2. tccelf.c +31 −1
tcc.c+2−0
@@ -9148,6 +9148,8 @@ void put_func_debug(Sym *sym) · 9147 unmodified lines
91489148 funcname, sym->type.t & VT_STATIC ? 'f' : 'F');
91499149 put_stabs_r(buf, N_FUN, 0, file->line_num, 0,
91509150 cur_text_section, sym->c);
9151+ /* //gr gdb wants a line at the function */
9152+ put_stabn(N_SLINE, 0, file->line_num, 0);
91519153 last_ind = 0;
91529154 last_line_num = 0;
91539155 }
tccelf.c+31−1
@@ -1821,6 +1821,11 @@ static int tcc_load_object_file(TCCState *s1, · 1820 unmodified lines
18211821 Elf32_Rel *rel, *rel_end;
18221822 Section *s;
18231823
1824+ int stab_index;
1825+ int stabstr_index;
1826+
1827+ stab_index = stabstr_index = 0;
1828+
18241829 if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
18251830 goto fail1;
18261831 if (ehdr.e_ident[0] != ELFMAG0 ||
@@ -1885,7 +1890,9 @@ static int tcc_load_object_file(TCCState *s1, · 58 unmodified lines
18851890 #ifdef TCC_ARM_EABI
18861891 sh->sh_type != SHT_ARM_EXIDX &&
18871892 #endif
1888− sh->sh_type != SHT_NOBITS)
1893+ sh->sh_type != SHT_NOBITS &&
1894+ strcmp(sh_name, ".stabstr")
1895+ )
18891896 continue;
18901897 if (sh->sh_addralign < 1)
18911898 sh->sh_addralign = 1;
@@ -1921,11 +1928,22 @@ static int tcc_load_object_file(TCCState *s1, · 29 unmodified lines
19211928
19221929 /* align start of section */
19231930 offset = s->data_offset;
1931+
1932+ if (0 == strcmp(sh_name, ".stab")) {
1933+ stab_index = i;
1934+ goto no_align;
1935+ }
1936+ if (0 == strcmp(sh_name, ".stabstr")) {
1937+ stabstr_index = i;
1938+ goto no_align;
1939+ }
1940+
19241941 size = sh->sh_addralign - 1;
19251942 offset = (offset + size) & ~size;
19261943 if (sh->sh_addralign > s->sh_addralign)
19271944 s->sh_addralign = sh->sh_addralign;
19281945 s->data_offset = offset;
1946+ no_align:
19291947 sm_table[i].offset = offset;
19301948 sm_table[i].s = s;
19311949 /* concatenate sections */
@@ -1941,6 +1959,18 @@ static int tcc_load_object_file(TCCState *s1, · 9 unmodified lines
19411959 next: ;
19421960 }
19431961
1962+ /* //gr relocate stab strings */
1963+ if (stab_index && stabstr_index) {
1964+ Stab_Sym *a, *b;
1965+ unsigned o;
1966+ s = sm_table[stab_index].s;
1967+ a = (Stab_Sym *)(s->data + sm_table[stab_index].offset);
1968+ b = (Stab_Sym *)(s->data + s->data_offset);
1969+ o = sm_table[stabstr_index].offset;
1970+ while (a < b)
1971+ a->n_strx += o, a++;
1972+ }
1973+
19441974 /* second short pass to update sh_link and sh_info fields of new
19451975 sections */
19461976 for(i = 1; i < ehdr.e_shnum; i++) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t