summaryrefslogtreecommitdiff
path: root/tests/elfstrmerge.c
Commit message (Collapse)AuthorAgeFilesLines
* Use fallthrough attribute.Joshua Watt2018-02-101-1/+2
| | | | | | | | | | | | | | | Use __attribute__ ((fallthrough)) to indicate switch case fall through instead of a comment. This ensures that the fallthrough warning is not triggered even if the file is pre-processed (hence stripping the comments) before it is compiled. The actual fallback implementation is hidden behind a FALLBACK macro in case the compiler doesn't support it. Finally, the -Wimplict-fallthrough warning was upgraded to only allow the attribute to satisfy it; a comment alone is no longer sufficient. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
* tests: Check symtabshdr instead of symtabndx in elfstrmerge.c.Mark Wielaard2018-01-251-2/+2
| | | | | | | | | Some gcc omptimization levels (-Og in particular) didn't see that when symtabndx != 0, then symtabshdr was certain to be initialized. Change the symtabndx == 0 check to symtabshdr == NULL and initialize symtabshdr to work around that. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Check for existence of mempcpyUlf Hermann2017-02-171-0/+1
| | | | | | If it doesn't exist, provide a definition based on memcpy. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* dwelf: Add string table functions from ebl.Mark Wielaard2016-08-031-15/+16
| | | | | | | | | | | | | | | | Move the strtab functions from libebl to libdw. Programs often want to create ELF/DWARF string tables. We don't want (static) linking against ebl since those are internal functions that might change. This introduces dwelf_strtab_init, dwelf_strtab_add, dwelf_strtab_add_len, dwelf_strtab_finalize, dwelf_strent_off, dwelf_strent_str and dwelf_strtab_free. Documentation for each has been added to libdwelf.h. The add fucntion got a variant that takes the length explicitly and finalize was changed to return NULL on out of memory instead of aborting. All code and tests now uses the new functions. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: elfstrmerge warn about STT_SECTION symbol for shstrhndx.Mark Wielaard2016-01-051-2/+7
| | | | | | | | | | | | | | Old linkers might have created an STT_SECTION symbol for the section header string table section, which isn't actually used. For now just warn about such symbols. If such a symbol would actually really be used (but why?) then we would have to handle it by removing it and rewriting the symbol table. This is a testsuite only change, but includes an extra test with files that have such STT_SECTION symbols to make sure it will be handled in case we "upgrade" the elfstrmerge test to a real utility. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Handle merged strtab/shstrtab string tables in strip and unstrip.Mark Wielaard2015-10-051-0/+667
ELF files can share the section header string table (e_shstrndx) with the symtab .strtab section. That might in some cases save a bit of space since symbols and sections might share some (sub)strings. To handle that eu-strip just needs to not unconditionally remove the .shstrtab section (it will be properly marked as used/unused as needed). eu-unstrip needs to make sure the section names are added to the strtab if it decides to rewrite that section. Also makes sure that eu-strip won't move around a SHT_NOBITS section that has SHF_ALLOC set. Although it is allowed to move such sections around, there is no benefit. And some tools might expect no allocated section to move around, not even a nobits section. It also makes it harder to do "roundtripping" sanity checks that make sure splitting a file with eu-strip and then reconstructed with eu-unstrip produce the same ELF file (as is done in the new run-strip-strmerge.sh). Introduces a somewhat large test generator elfstrmerge.c that will hopefully turn into a more generic string table merger program. Signed-off-by: Mark Wielaard <mjw@redhat.com>