diff options
| author | Michael Matz <matz@suse.de> | 2017-05-06 07:30:44 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2017-05-06 07:30:44 +0200 |
| commit | 600018ce474b1ecb7ea51f9fa0b005000ccc9101 (patch) | |
| tree | 9eeb05995e746c1aba6cba8235fd986815757f5e /tccelf.c | |
| parent | ff998900b163e96c52a4fefc71736ed34626ed86 (diff) | |
| download | tinycc-600018ce474b1ecb7ea51f9fa0b005000ccc9101.tar.gz tinycc-600018ce474b1ecb7ea51f9fa0b005000ccc9101.tar.bz2 | |
elf: Ignore SHF_COMPRESSED sections
some newer systems have debug sections compressed by default, which
includes those in the crt[1in].o startup files. These can't simply
be concatenated like all others (which leads to invalid section contents
ultimately making gdb fail) but need special handling.
Instead of that special handling (decompressing, which in turn requires
linking against zlib) let's just ignore such sections, even though that
means to also ignore all other debug sections from that particular input
file. Our own generated files of course don't have the problem.
Diffstat (limited to 'tccelf.c')
| -rw-r--r-- | tccelf.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -2194,7 +2194,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, { ElfW(Ehdr) ehdr; ElfW(Shdr) *shdr, *sh; - int size, i, j, offset, offseti, nb_syms, sym_index, ret; + int size, i, j, offset, offseti, nb_syms, sym_index, ret, seencompressed; unsigned char *strsec, *strtab; int *old_to_new_syms; char *sh_name, *name; @@ -2232,6 +2232,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, symtab = NULL; strtab = NULL; nb_syms = 0; + seencompressed = 0; for(i = 1; i < ehdr.e_shnum; i++) { sh = &shdr[i]; if (sh->sh_type == SHT_SYMTAB) { @@ -2249,6 +2250,8 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, sh = &shdr[sh->sh_link]; strtab = load_data(fd, file_offset + sh->sh_offset, sh->sh_size); } + if (sh->sh_flags & SHF_COMPRESSED) + seencompressed = 1; } /* now examine each section and try to merge its content with the @@ -2272,6 +2275,12 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, strcmp(sh_name, ".stabstr") ) continue; + if (seencompressed + && (!strncmp(sh_name, ".debug_", sizeof(".debug_")-1) + || (sh->sh_type == SHT_RELX + && !strncmp((char*)strsec + shdr[sh->sh_info].sh_name, + ".debug_", sizeof(".debug_")-1)))) + continue; if (sh->sh_addralign < 1) sh->sh_addralign = 1; /* find corresponding section, if any */ |
