From: Ulrich Drepper Date: Sun, 7 Aug 2005 05:33:07 +0000 (+0000) Subject: Relax elflint a bit. X-Git-Tag: elfutils-0.120~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=637963b564240fe6db4908b28238b75aa0758a06;p=thirdparty%2Felfutils.git Relax elflint a bit. Run elflint on all programs and DSOs. --- diff --git a/NEWS b/NEWS index 264742f96..d03953abc 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +Version 0.113: + +elflint: relax a bit. Allow version definitions for defined symbols against +DSO versions also for symbols in nobits sections. Allow .rodata section +to have STRINGS and MERGE flag set. + Version 0.112: elfcmp: some more relaxation. diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in index a86f2139d..9cc91adee 100644 --- a/config/elfutils.spec.in +++ b/config/elfutils.spec.in @@ -183,6 +183,15 @@ rm -rf ${RPM_BUILD_ROOT} %{_libdir}/libelf.so %changelog +* Sat Aug 6 2005 Ulrich Drepper <@redhat.com> 0.113-1 +- elflint: relax a bit. Allow version definitions for defined symbols ag +ainstDSO versions also for symbols in nobits sections. Allow .rodata +sectionto have STRINGS and MERGE flag set. + +* Sat Aug 6 2005 Ulrich Drepper <@redhat.com> 0.113-1 +- elflint: relax a bit. Allow version definitions for defined symbols ag +ainstDSO versions also for symbols in nobits sections. + * Fri Aug 5 2005 Ulrich Drepper <@redhat.com> 0.112-1 - elfcmp: some more relaxation. - elflint: many more tests, especially regarding to symbol versioning. diff --git a/src/ChangeLog b/src/ChangeLog index cf315fff2..a384ed676 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2005-08-06 Ulrich Drepper + * elflint.c (in_nobits_scn): New function. + (check_versym): Allow references for defined symbols against versions + of other DSOs also for symbols in nobits sections. + Move a few variables around. + * Makefile.am (AM_CFLAGS): Avoid duplication. Link with statis libs if BUILD_STATIC. diff --git a/src/elflint.c b/src/elflint.c index aee3e71d9..ecf6a723e 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -1813,61 +1813,6 @@ section [%2d] '%s' is contained in more than one section group\n"), } -static bool has_loadable_segment; -static bool has_interp_segment; - -static const struct -{ - const char *name; - size_t namelen; - GElf_Word type; - enum { unused, exact, atleast } attrflag; - GElf_Word attr; - GElf_Word attr2; -} special_sections[] = - { - /* See figure 4-14 in the gABI. */ - { ".bss", 5, SHT_NOBITS, exact, SHF_ALLOC | SHF_WRITE, 0 }, - { ".comment", 8, SHT_PROGBITS, exact, 0, 0 }, - { ".data", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE, 0 }, - { ".data1", 7, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE, 0 }, - { ".debug", 7, SHT_PROGBITS, exact, 0, 0 }, - { ".dynamic", 9, SHT_DYNAMIC, atleast, SHF_ALLOC, SHF_WRITE }, - { ".dynstr", 8, SHT_STRTAB, exact, SHF_ALLOC, 0 }, - { ".dynsym", 8, SHT_DYNSYM, exact, SHF_ALLOC, 0 }, - { ".fini", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_EXECINSTR, 0 }, - { ".fini_array", 12, SHT_FINI_ARRAY, exact, SHF_ALLOC | SHF_WRITE, 0 }, - { ".got", 5, SHT_PROGBITS, unused, 0, 0 }, // XXX more info? - { ".hash", 6, SHT_HASH, exact, SHF_ALLOC, 0 }, - { ".init", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_EXECINSTR, 0 }, - { ".init_array", 12, SHT_INIT_ARRAY, exact, SHF_ALLOC | SHF_WRITE, 0 }, - { ".interp", 8, SHT_PROGBITS, atleast, 0, SHF_ALLOC }, // XXX more tests? - { ".line", 6, SHT_PROGBITS, exact, 0, 0 }, - { ".note", 6, SHT_NOTE, exact, 0, 0 }, - { ".plt", 5, SHT_PROGBITS, unused, 0, 0 }, // XXX more tests - { ".preinit_array", 15, SHT_PREINIT_ARRAY, exact, SHF_ALLOC | SHF_WRITE, 0 }, - { ".rela", 5, SHT_RELA, atleast, 0, SHF_ALLOC }, // XXX more tests - { ".rel", 4, SHT_REL, atleast, 0, SHF_ALLOC }, // XXX more tests - { ".rodata", 8, SHT_PROGBITS, exact, SHF_ALLOC, 0 }, - { ".rodata1", 9, SHT_PROGBITS, exact, SHF_ALLOC, 0 }, - { ".shstrtab", 10, SHT_STRTAB, exact, 0, 0 }, - { ".strtab", 8, SHT_STRTAB, atleast, 0, SHF_ALLOC }, // XXX more tests - { ".symtab", 8, SHT_SYMTAB, atleast, 0, SHF_ALLOC }, // XXX more tests - { ".symtab_shndx", 14, SHT_SYMTAB_SHNDX, atleast, 0, SHF_ALLOC }, // XXX more tests - { ".tbss", 6, SHT_NOBITS, exact, SHF_ALLOC | SHF_WRITE | SHF_TLS, 0 }, - { ".tdata", 7, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE | SHF_TLS, 0 }, - { ".tdata1", 8, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE | SHF_TLS, 0 }, - { ".text", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_EXECINSTR, 0 }, - - /* The following are GNU extensions. */ - { ".gnu.version", 13, SHT_GNU_versym, exact, SHF_ALLOC, 0 }, - { ".gnu.version_d", 15, SHT_GNU_verdef, exact, SHF_ALLOC, 0 }, - { ".gnu.version_r", 15, SHT_GNU_verneed, exact, SHF_ALLOC, 0 } - }; -#define nspecial_sections \ - (sizeof (special_sections) / sizeof (special_sections[0])) - - static const char * section_flags_string (GElf_Word flags, char *buf, size_t len) { @@ -1972,6 +1917,15 @@ has_copy_reloc (Ebl *ebl, unsigned int symscnndx, unsigned int symndx) } +static int +in_nobits_scn (Ebl *ebl, unsigned int shndx) +{ + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, shndx), &shdr_mem); + return shdr != NULL && shdr->sh_type == SHT_NOBITS; +} + + static struct version_namelist { const char *objname; @@ -2118,7 +2072,8 @@ section [%2d] '%s': symbol %d: version index %d is for defined version\n"), { /* Unless this symbol has a copy relocation associated this must not happen. */ - if (!has_copy_reloc (ebl, shdr->sh_link, cnt)) + if (!has_copy_reloc (ebl, shdr->sh_link, cnt) + && !in_nobits_scn (ebl, sym->st_shndx)) ERROR (gettext ("\ section [%2d] '%s': symbol %d: version index %d is for requested version\n"), idx, section_name (ebl, idx), cnt, (int) *versym); @@ -2476,6 +2431,61 @@ section [%2d] '%s': unknown parent version '%s'\n"), } +static bool has_loadable_segment; +static bool has_interp_segment; + +static const struct +{ + const char *name; + size_t namelen; + GElf_Word type; + enum { unused, exact, atleast } attrflag; + GElf_Word attr; + GElf_Word attr2; +} special_sections[] = + { + /* See figure 4-14 in the gABI. */ + { ".bss", 5, SHT_NOBITS, exact, SHF_ALLOC | SHF_WRITE, 0 }, + { ".comment", 8, SHT_PROGBITS, exact, 0, 0 }, + { ".data", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE, 0 }, + { ".data1", 7, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE, 0 }, + { ".debug", 7, SHT_PROGBITS, exact, 0, 0 }, + { ".dynamic", 9, SHT_DYNAMIC, atleast, SHF_ALLOC, SHF_WRITE }, + { ".dynstr", 8, SHT_STRTAB, exact, SHF_ALLOC, 0 }, + { ".dynsym", 8, SHT_DYNSYM, exact, SHF_ALLOC, 0 }, + { ".fini", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_EXECINSTR, 0 }, + { ".fini_array", 12, SHT_FINI_ARRAY, exact, SHF_ALLOC | SHF_WRITE, 0 }, + { ".got", 5, SHT_PROGBITS, unused, 0, 0 }, // XXX more info? + { ".hash", 6, SHT_HASH, exact, SHF_ALLOC, 0 }, + { ".init", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_EXECINSTR, 0 }, + { ".init_array", 12, SHT_INIT_ARRAY, exact, SHF_ALLOC | SHF_WRITE, 0 }, + { ".interp", 8, SHT_PROGBITS, atleast, 0, SHF_ALLOC }, // XXX more tests? + { ".line", 6, SHT_PROGBITS, exact, 0, 0 }, + { ".note", 6, SHT_NOTE, exact, 0, 0 }, + { ".plt", 5, SHT_PROGBITS, unused, 0, 0 }, // XXX more tests + { ".preinit_array", 15, SHT_PREINIT_ARRAY, exact, SHF_ALLOC | SHF_WRITE, 0 }, + { ".rela", 5, SHT_RELA, atleast, 0, SHF_ALLOC }, // XXX more tests + { ".rel", 4, SHT_REL, atleast, 0, SHF_ALLOC }, // XXX more tests + { ".rodata", 8, SHT_PROGBITS, atleast, SHF_ALLOC, SHF_MERGE | SHF_STRINGS }, + { ".rodata1", 9, SHT_PROGBITS, atleast, SHF_ALLOC, SHF_MERGE | SHF_STRINGS }, + { ".shstrtab", 10, SHT_STRTAB, exact, 0, 0 }, + { ".strtab", 8, SHT_STRTAB, atleast, 0, SHF_ALLOC }, // XXX more tests + { ".symtab", 8, SHT_SYMTAB, atleast, 0, SHF_ALLOC }, // XXX more tests + { ".symtab_shndx", 14, SHT_SYMTAB_SHNDX, atleast, 0, SHF_ALLOC }, // XXX more tests + { ".tbss", 6, SHT_NOBITS, exact, SHF_ALLOC | SHF_WRITE | SHF_TLS, 0 }, + { ".tdata", 7, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE | SHF_TLS, 0 }, + { ".tdata1", 8, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE | SHF_TLS, 0 }, + { ".text", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_EXECINSTR, 0 }, + + /* The following are GNU extensions. */ + { ".gnu.version", 13, SHT_GNU_versym, exact, SHF_ALLOC, 0 }, + { ".gnu.version_d", 15, SHT_GNU_verdef, exact, SHF_ALLOC, 0 }, + { ".gnu.version_r", 15, SHT_GNU_verneed, exact, SHF_ALLOC, 0 } + }; +#define nspecial_sections \ + (sizeof (special_sections) / sizeof (special_sections[0])) + + static void check_sections (Ebl *ebl, GElf_Ehdr *ehdr) { diff --git a/tests/ChangeLog b/tests/ChangeLog index 25474b066..6373df239 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,9 @@ 2005-08-06 Ulrich Drepper + * run-elflint-self.sh: New file. + * Makefile.am (TESTS): Add run-elflint-self.sh. + (EXTRA_DIST): Likewise. + * Makefile.am: Link with statis libs if BUILD_STATIC. (dwflmodtest_LDADD): Also link with -ldl. diff --git a/tests/Makefile.am b/tests/Makefile.am index c0c23c093..407426a4e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -44,7 +44,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ msg_tst newscn run-strip-test.sh run-strip-test2.sh \ run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \ run-strip-test6.sh run-ecp-test.sh run-ecp-test2.sh \ - run-elflint-test.sh + run-elflint-test.sh run-elflint-self.sh # run-show-ciefde.sh EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ @@ -58,6 +58,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ testfile13.bz2 run-strip-test3.sh run-allfcts.sh \ run-line2addr.sh run-elflint-test.sh testfile14.bz2 \ run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \ + run-elflint-self.sh \ testfile15.bz2 testfile15.debug.bz2 \ testfile16.bz2 testfile16.debug.bz2 \ testfile17.bz2 testfile17.debug.bz2 \