| @@ -1821,6 +1821,11 @@ static int tcc_load_object_file(TCCState *s1, · 1820 unmodified lines |
| 1821 | Elf32_Rel *rel, *rel_end; | 1821 | Elf32_Rel *rel, *rel_end; |
| 1822 | Section *s; | 1822 | Section *s; |
| 1823 | | 1823 | |
| | 1824 | int stab_index; |
| | 1825 | int stabstr_index; |
| | 1826 | |
| | 1827 | stab_index = stabstr_index = 0; |
| | 1828 | |
| 1824 | if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) | 1829 | if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) |
| 1825 | goto fail1; | 1830 | goto fail1; |
| 1826 | if (ehdr.e_ident[0] != ELFMAG0 || | 1831 | if (ehdr.e_ident[0] != ELFMAG0 || |
| @@ -1885,7 +1890,9 @@ static int tcc_load_object_file(TCCState *s1, · 58 unmodified lines |
| 1885 | #ifdef TCC_ARM_EABI | 1890 | #ifdef TCC_ARM_EABI |
| 1886 | sh->sh_type != SHT_ARM_EXIDX && | 1891 | sh->sh_type != SHT_ARM_EXIDX && |
| 1887 | #endif | 1892 | #endif |
| 1888 | sh->sh_type != SHT_NOBITS) | 1893 | sh->sh_type != SHT_NOBITS && |
| | 1894 | strcmp(sh_name, ".stabstr") |
| | 1895 | ) |
| 1889 | continue; | 1896 | continue; |
| 1890 | if (sh->sh_addralign < 1) | 1897 | if (sh->sh_addralign < 1) |
| 1891 | sh->sh_addralign = 1; | 1898 | sh->sh_addralign = 1; |
| @@ -1921,11 +1928,22 @@ static int tcc_load_object_file(TCCState *s1, · 29 unmodified lines |
| 1921 | | 1928 | |
| 1922 | /* align start of section */ | 1929 | /* align start of section */ |
| 1923 | offset = s->data_offset; | 1930 | 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 | |
| 1924 | size = sh->sh_addralign - 1; | 1941 | size = sh->sh_addralign - 1; |
| 1925 | offset = (offset + size) & ~size; | 1942 | offset = (offset + size) & ~size; |
| 1926 | if (sh->sh_addralign > s->sh_addralign) | 1943 | if (sh->sh_addralign > s->sh_addralign) |
| 1927 | s->sh_addralign = sh->sh_addralign; | 1944 | s->sh_addralign = sh->sh_addralign; |
| 1928 | s->data_offset = offset; | 1945 | s->data_offset = offset; |
| | 1946 | no_align: |
| 1929 | sm_table[i].offset = offset; | 1947 | sm_table[i].offset = offset; |
| 1930 | sm_table[i].s = s; | 1948 | sm_table[i].s = s; |
| 1931 | /* concatenate sections */ | 1949 | /* concatenate sections */ |
| @@ -1941,6 +1959,18 @@ static int tcc_load_object_file(TCCState *s1, · 9 unmodified lines |
| 1941 | next: ; | 1959 | next: ; |
| 1942 | } | 1960 | } |
| 1943 | | 1961 | |
| | 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 | |
| 1944 | /* second short pass to update sh_link and sh_info fields of new | 1974 | /* second short pass to update sh_link and sh_info fields of new |
| 1945 | sections */ | 1975 | sections */ |
| 1946 | for(i = 1; i < ehdr.e_shnum; i++) { | 1976 | for(i = 1; i < ehdr.e_shnum; i++) { |