summaryrefslogtreecommitdiffstats
path: root/libebl
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'elfutils-0.175'Ulf Hermann2019-01-097-16/+422
|\ | | | | | | | | | | elfutils 0.175 release Change-Id: I409f41767af349d0521351dd733879ad31c65aab
| * libebl: Don't update w, t and len unnecessarily in ebl_object_note_type_name.Mark Wielaard2018-11-152-5/+8
| | | | | | | | | | | | Harmless, but useless. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Handle GNU Build Attribute ELF Notes.Mark Wielaard2018-11-134-4/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GNU Build Attribute ELF Notes are generated by the GCC annobin plugin and described at https://fedoraproject.org/wiki/Toolchain/Watermark Unfortunately the constants aren't yet described in the standard glibc elf.h so they have been added to the elfutils specific elf-knowledge.h. The notes abuse the name owner field to encode some data not in the description. This makes it a bit hard to parse. We have to match the note owner name prefix (to "GA") to be sure the type is valid. We also cannot rely on the owner name being a valid C string since the attribute name and value can contain zero (terminators). So pass around namesz to the ebl note parsing functions. eu-elflint will recognize and eu-readelf -n will now show the notes: Note section [27] '.gnu.build.attributes' of 56080 bytes at offset 0x114564: Owner Data size Type GA 16 GNU Build Attribute OPEN Address Range: 0x2f30f - 0x2f30f VERSION: "3p8" GA 0 GNU Build Attribute OPEN TOOL: "gcc 8.2.1 20180801" GA 0 GNU Build Attribute OPEN "GOW": 45 GA 0 GNU Build Attribute OPEN STACK_PROT: 0 GA 0 GNU Build Attribute OPEN "stack_clash": TRUE GA 0 GNU Build Attribute OPEN "cf_protection": 0 GA 0 GNU Build Attribute OPEN "GLIBCXX_ASSERTIONS": TRUE GA 0 GNU Build Attribute OPEN "FORTIFY": 0 GA 0 GNU Build Attribute OPEN PIC: 3 GA 0 GNU Build Attribute OPEN SHORT_ENUM: FALSE GA 0 GNU Build Attribute OPEN ABI: c001100000012 GA 0 GNU Build Attribute OPEN "stack_realign": FALSE A new test was added to run-readelf -n for the existing annobin file. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Recognize NT_VERSION notes.Mark Wielaard2018-11-134-4/+27
| | | | | | | | | | | | | | | | NT_VERSION notes are emitted by the gas .version directive. They have an empty description and (ab)use the owner name to store the version data string. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Recognize and parse GNU Property notes.Mark Wielaard2018-10-293-1/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GNU Property notes are different from normal notes because they use variable alignment/padding of their fields. They are 8 byte aligned, but use 4 byte fields. The name is aligned at 4 bytes and padded so that, the desc is aligned at 8 bytes. The whole note is padded to 8 bytes again. For normal notes all fields are both 4 bytes wide and 4 bytes aligned. To recognize these new kind of ELF Notes a new Elf_Type is introduced, ELF_T_NHDR8. This type is used in the xlate functions to determine how to align and pad the various fields. Since the fields themselves can now have different alignments we will have to keep track of the current alignement and use either NOTE_ALIGN4 or NOTE_ALIGN8 to determine the padding. To set the correct Elf_Type on the Elf_Data we use either the section sh_addralign or the segment p_align values. Assuming 8 means the section or segment contains the new style notes, otherwise normal notes. When we cannot determine the "alignment" directly, like when parsing special kernel sys files, we check the name "GNU" and type "GNU_PROPERTY_TYPE_0" fields. ebl_object_note now parses the new NT_GNU_PROPERTY_TYPE_0 and can extract the GNU_PROPERTY_STACK_SIZE, GNU_PROPERTY_NO_COPY_ON_PROTECTED and GNU_PROPERTY_X86_FEATURE_1_AND types GNU_PROPERTY_X86_FEATURE_1_IBT and GNU_PROPERTY_X86_FEATURE_1_SHSTK. Tests are added for extracting the note from sections or segments as set by gcc -fcf-protection. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Handle ADD/SUB relocationsAndreas Schwab2018-10-135-7/+17
| | | | | | | | | | | | This adds support for ADD and SUB relocations as seen on RISC-V. Signed-off-by: Andreas Schwab <schwab@suse.de>
* | Merge tag 'elfutils-0.174'Ulf Hermann2018-10-116-10/+28
|\| | | | | | | | | | | elfutils 0.174 release Change-Id: Ibcbdfca61cf0b65391ab6d0ad00f18ba61027e07
| * libebl: Use elf_getshdrstrndx in ebl_section_strip_p.Mark Wielaard2018-09-133-3/+12
| | | | | | | | | | | | | | | | | | | | The ebl_section_strip_p function used the Ehdr e_shstrndx field to get at the name of the (debug) sections. This is not correct if there are more than SHN_LORESERVE sections. Use elf_getshdrstrndx to get at the shstrtab section. And drop the Ehdr argument that isn't necessary anymore. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * backends: Always use elf_getshdrstrndx in check_special_symbol.Mark Wielaard2018-09-135-6/+12
| | | | | | | | | | | | | | | | | | | | The check_special_symbol backend functions used the Ehdr e_shstrndx field to get at the name of sections. This is not correct if there are more than SHN_LORESERVE sections. Always use elf_getshdrstrndx to get the shstrtab section. And drop the Ehdr argument that isn't necessary anymore. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Consolidate error.h inclusion in system.hRoss Burton2018-07-052-1/+4
| | | | | | | | | | | | | | | | | | error.h isn't standard and so isn't part of the musl C library. To easy future porting, consolidate the inclusion of error.h into system.h. https://sourceware.org/bugzilla/show_bug.cgi?id=21008 Signed-off-by: Ross Burton <ross.burton@intel.com>
* | Merge tag 'elfutils-0.173'Ulf Hermann2018-07-135-5/+43
|\| | | | | | | | | | | elfutils 0.173 release Change-Id: I83dc56dd15c26fe7acf4ce73c29df65b8b65e757
| * libebl: Add new DWARF5 debug section names to default_debugscn_p.Mark Wielaard2018-05-062-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | This adds the new DWARF5 debug section names .debug_addr, .debug_line_str, .debug_loclists, .debug_names, .debug_rnglists and .debug_str_offsets. This makes sure eu-strip knows to strip them away. Note that it doesn't add the .dwo variants, nor the .dwp only section names .debug_cu_index and .debug_tu_index, nor the .debug_sup section for supplemental DWARF files. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Add support for RISC-VAndreas Schwab2018-04-232-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements initial support for the RISC-V architecture. It has been tested with qemu linux-user emulation <https://build.opensuse.org/package/live_build_log/openSUSE:Factory:RISCV/elfutils/standard/riscv64>, with the following unresolved issues FAIL: run-strip-strmerge.sh =========================== elflint /home/abuild/rpmbuild/BUILD/elfutils-0.170/tests/elfstrmerge section [32] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x51c0 does not match .got section address 0x5010 section [32] '.symtab': symbol 119: st_value out of bounds FAIL run-strip-strmerge.sh (exit status: 1) FAIL: run-elflint-self.sh ========================= section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x6220 does not match .got section address 0x6008 section [33] '.symtab': symbol 135: st_value out of bounds *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/addr2line section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x91d8 does not match .got section address 0x9040 section [33] '.symtab': symbol 163: st_value out of bounds *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elfcmp section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x1a2a0 does not match .got section address 0x1a040 section [33] '.symtab': symbol 267: st_value out of bounds *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0xd418 does not match .got section address 0xd0f0 section [33] '.symtab': symbol 238: st_value out of bounds *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/nm section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0xa2d0 does not match .got section address 0xa0b0 section [33] '.symtab': symbol 193: st_value out of bounds *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/objdump section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x2e5b8 does not match .got section address 0x2e058 section [33] '.symtab': symbol 410: st_value out of bounds *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/readelf section [32] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x171b8 does not match .got section address 0x17010 *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/libelf/libelf.so section [32] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x3a5b0 does not match .got section address 0x3a0d8 *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/libdw/libdw.so section [31] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0xd0c8 does not match .got section address 0xd008 *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/backends/libebl_i386.so section [31] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0xf0c8 does not match .got section address 0xf008 *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/backends/libebl_x86_64.so FAIL run-elflint-self.sh (exit status: 1) FAIL: run-native-test.sh ======================== /home/abuild/rpmbuild/BUILD/elfutils-0.170/tests/allregs: dwfl_module_register_names: no backend registers known FAIL run-native-test.sh (exit status: 1) FAIL: run-backtrace-native-core.sh ================================== backtrace: backtrace.c:111: callback_verify: Assertion `symname && strcmp (symname, "raise") == 0' failed. ./test-subr.sh: line 84: 26040 Aborted (core dumped) LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" $VALGRIND_CMD "$@" backtrace-child-core.26027: no main rmdir: failed to remove 'test-26016': Directory not empty FAIL run-backtrace-native-core.sh (exit status: 1) In addition, all tests that use ptrace are failing as linux-user emulation does not implement it. There are no regressions for a x86_64 build. Signed-off-by: Andreas Schwab <schwab@suse.de>
| * libebl: Handle SYMTAB_SHNDX in ebl_dynamic_tag_name.Mark Wielaard2018-03-162-1/+9
| | | | | | | | | | | | | | | | | | | | SYMTAB_SHNDX was introduced when elf.h was imported, but not yet handled in ebl_dynamic_tag_name. Handle it and add an eu_static_assert to make sure stdtags always contains DT_NUM entries. https://sourceware.org/bugzilla/show_bug.cgi?id=22976 Signed-off-by: Mark Wielaard <mark@klomp.org>
| * libebl: Allow SHT_NOTE as relocation target type.Mark Wielaard2018-02-222-0/+6
| | | | | | | | | | | | | | | | | | | | | | eu-elflint uses ebl_check_reloc_target_type to determine whether a section is a valid relocation target. In Fedora rawhide there are new ELF notes (annobin) which have relocations against them in ET_REL files. eu-elflint currently flags these as invalid. It looks like that is not correct. I cannot find any reason an SHT_NOTE section cannot have relocations against it. So this patch allows them. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Use fallthrough attribute.Joshua Watt2018-02-102-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Check for -z,defs, -z,relro, -fPIC, -fPIE before using themUlf Hermann2017-08-182-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Those flags are not available on all platforms, and omitting them when not available will not cause any harm. In particular: -z,defs disallows undefined symbols in object files. This option is unsupported if the target binary format enforces the same condition already. Furthermore it is only a compile time sanity check. When it is omitted, the same binary is produced. -z,relro instructs the loader to mark sections read-only after loading the library, where possible. This is a hardening mechanism. If it is unavailable, the functionality of the code is not affected in any way. -fPIC instructs the compiler to produce position independent code. While this is preferable to relocatable code, relocatable code also works and may even be faster. Relocatable code might just be loaded into memory multiple times for different processes. -fPIE is the same thing as -fPIC for executables rather than shared libraries. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* | Merge tag 'elfutils-0.170'Ulf Hermann2017-08-177-5/+80
|\| | | | | | | | | | | elfutils 0.170 release Change-Id: I37d03645902b9f0a9fb708af1551db8843537799
| * ppc64: Add HTM SPRs support to readelfGustavo Romero2017-07-252-0/+5
| | | | | | | | | | | | | | | | | | | | Since POWER8, PowerPC 64 supports Hardware Transactional Memory, which has three special purpose registers associated to it: tfhar, tfiar, and texasr. This commit add HTM SPRs set as known note type so it's possible to use 'readelf --notes' to inspect the HTM SPRs in a coredump file generated in such a machines. Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>
| * strip: Deal with ARM data marker symbols pointing to debug sections.Mark Wielaard2017-07-246-5/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ARM data marker symbols "$d" indicate the start of a sequence of data items in a section. For data only sections no data marker symbol is necessary, but may be put pointing to the start of the section. binutils however has a bug which places a data marker symbol somewhere inside the section (at least for .debug_frame). https://sourceware.org/bugzilla/show_bug.cgi?id=21809 When strip finds a symbol pointing to a debug section that would be put into the .debug file then it will copy over the whole symbol table. This isn't necessary because the symbol is redundant. Add an ebl hook to recognize data marker symbols with implementations for arm and aarch64. Use it in strip to strip such symbols from the symbol table if they point to a debug section. Signed-off-by: Mark Wielaard <mark@klomp.org>
| * Make __attribute__ conditional in all installed headersUlf Hermann2017-05-022-3/+7
| | | | | | | | | | | | | | | | | | | | __attribute__ is a GNU extension. If we want to link against the libraries using a different compiler, it needs to be disabled. It was already disabled in libdw.h, and this patch extends this to the other headers. We move the defines to libelf.h as that is included in all the others. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* | Provide a windows-specific ORIGIN_PATH for eblopenbackendUlf Hermann2017-05-082-0/+9
| | | | | | | | | | | | | | | | $ORIGIN and $LIB are not supported by all implementations of dlopen() and on windows we need backslashes as directory separators. Change-Id: I7394fcda65fa0eca8e21e4d1035fd890dac0b32d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Generalize library namesUlf Hermann2017-04-283-4/+13
| | | | | | | | | | | | | | | | | | On windows library names end with ".dll" and the prefix "lib" us usually omitted. Take this into account and also drop the $(EXEEXT) workaround. We don't need to use noinst_PROGRAMS as there is also noinst_DATA. Change-Id: I7e4ba2432811d5ad85051ea0c9d5674eabf79b3c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Check for -z,defs, -z,relro, -fPIC, -fPIE before using themUlf Hermann2017-04-282-1/+5
| | | | | | | | | | | | | | | | | | On windows those aren't needed because the link results are no ELF files and all code is position independent anyway. gcc then complains about them, which is in turn caught by -Werror. Change-Id: Ie3d600b7c430698fc3d867a986a4d48f7ad1bbec Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Drop handrolled or #ifdef'ed libc replacementsUlf Hermann2017-04-283-2/+5
| | | | | | | | | | | | | | | | | | mempcpy, memrchr, rawmemchr, and argp are provided by gnulib now. We don't need to define them locally and we don't need to search for an external libargp. Change-Id: I131ca4bc2d77c597b99c296c28259a3600e5d1b5 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Make __attribute__ conditional in all installed headersUlf Hermann2017-04-212-3/+7
|/ | | | | | | | | | | __attribute__ is a GNU extension. If we want to link against the libraries using a different compiler, it needs to be disabled. It was already disabled in libdw.h, and this patch extends this to the other headers. We move the defines to libelf.h as that is included in all the others. Change-Id: I6e22674641f19f5a8820e2c7c7ec46f2fd70a8af Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Check for existence of mempcpyUlf Hermann2017-02-173-0/+7
| | | | | | 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-034-384/+14
| | | | | | | | | | | | | | | | 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>
* Remove eu-ld and unused code.Mark Wielaard2016-08-039-908/+23
| | | | | | | | Nobody has hacked on eu-ld in a very long time. It didn't really work. And we didn't install it by default in the spec file. Remove sources, the build rules and any (now) unused code. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Add support for BPFRichard Henderson2016-06-283-1/+7
| | | | Signed-off-by: Richard Henderson <rth@redhat.com>
* Add support for m68kAndreas Schwab2016-05-232-1/+5
| | | | Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
* Add NT_ARM_SYSTEM_CALL aarch64 syscall regset.Mark Wielaard2016-02-151-0/+1
| | | | | | | | | Linux kernel 3.18 added the NT_ARM_SYSTEM_CALL regset for aarch64. Recognize and print this new core item. https://bugzilla.redhat.com/show_bug.cgi?id=1285613 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl: Don't assume ELF notes are "GNU" when unknown, recognize "Go" notes.Mark Wielaard2016-02-152-1/+40
| | | | | | | | | | | | We used to assume any unknown ELF note provider name was "GNU" and didn't recognize any of the "Go" provider types. We now check the provider name explictly in ebl_object_note_type_name and recognize the following Go note names: PKGLIST, ABIHASH, DEPS and BUILDID. But there is no attempt yet in ebl_object_note to decode the description of these notes. https://bugzilla.redhat.com/show_bug.cgi?id=1295951 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl: Fix missing brackets around if statement body.Mark Wielaard2016-01-092-180/+187
| | | | | | | | | | | | | | | | | | GCC6 [will have] a nice new warning that showed a real bug: elfutils/libebl/eblobjnote.c: In function ‘ebl_object_note’: elfutils/libebl/eblobjnote.c:135:5: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation] switch (type) ^~~~~~ elfutils/libebl/eblobjnote.c:45:3: note: ...this ‘if’ clause, but it is not if (! ebl->object_note (name, type, descsz, desc)) ^~ And indeed, it should have been under the if, but wasn't because of missing brackets. Added brackets (and reindent). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Use elf_compress[_gnu] to decompress string, symbol and reloc data.Mark Wielaard2016-01-062-1/+7
| | | | | | | | | This makes usage of the libdwfl symbol functions work out of the box even when some sections (string, symbol or xndx) are compressed. For ET_REL files this makes relocations just work by making sure the target section is decompressed first before relocations are applied. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl: new backend attribute ra_offset.Jose E. Marchesi2016-01-034-0/+24
| | | | | | | | Some backends need to fine-tune the return address as fetched from the corresponding CFI register. This patch adds a new backend attribute ra_offset and the corresponding ebl_ra_offset getter function. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* Use -fPIC instead of -fpic when generating PIC code.Jose E. Marchesi2015-10-062-1/+6
| | | | | | | This avoids relocation overflows in sparc/sparc64 targets while linking, where the reachable data using -fpic is only 4kb. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* Remove old-style function definitions.Mark Wielaard2015-09-2342-180/+60
| | | | | | | We already require -std=gnu99 and old-style function definitions might hide some compiler warnings. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Remove redundant NULL tests.Chih-Hung Hsieh2015-09-145-5/+15
| | | | | | | | GCC6 and Clang give warnings on redundant NULL tests of parameters that are declared with __nonnull_attribute__. Signed-off-by: Chih-Hung Hsieh <chh@google.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Replace some K&R function definitions with ansi-C definitions.Chih-Hung Hsieh2015-09-073-5/+8
| | | | | Signed-off-by: Chih-Hung Hsieh <chh@google.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl: SHT_(INIT|FINI|PREINIT)_ARRAY are valid targets for relocation.Mark Wielaard2015-06-142-5/+18
| | | | | | | Seen in run-elflint-self.sh for size.o when build with --enable-gcov. https://bugzilla.redhat.com/show_bug.cgi?id=1230798 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl: Don't blow up stack when processing large NT_GNU_ABI_TAG.Mark Wielaard2015-05-272-2/+22
| | | | | | | Normally an NT_GNU_ABI_TAG is large, just 4 words (16 bytes). Only use stack allocated conversion buf for small (max 16 words) notes. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl: Use static number for array stack allocation in openbackend.Mark Wielaard2015-05-272-2/+13
| | | | | | | | | Help the compiler see we stack allocate a small array. Add assert to check no machine prefix is ever larger than 16. Current maximum number is 7. This prevents gcc warning about possible unbounded stack usage with -Wstack-usage. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* s/Really, not guarantee/Really, no guarantee/gMark Wielaard2015-01-271-1/+1
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl.h: Add comment from README that this is completely UNSUPPORTED.Mark Wielaard2015-01-272-1/+19
| | | | | | | Make it really, really clear that the libebl interface is NOT source and NOT abi compatible and we will break any users. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Use elf_getphdrnum instead of accessing ehdr->e_phnum directly.Mark Wielaard2014-11-265-9/+14
| | | | | | | Using elf_getphdrnum lets us handle ELF files that use more than PN_XNUM phdrs. And guards against some corrupt files. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Check elf_strptr didn't fail getting section name.Mark Wielaard2014-11-172-2/+6
| | | | | | | | Since elf_strptr can fail and return NULL we should always check the result before usage. Debug sections are only handled by section name, so make sure the name actually exists. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl: Add ebl_func_addr_mask plus ARM backend implementation.Mark Wielaard2014-06-225-4/+34
| | | | | | | | | | | | | | The ARM EABI says that the zero bit of function symbol st_value indicates whether the symbol points to a THUMB or ARM function. Also the return value address in an unwind will contain the same extra bit to indicate whether to return to a regular ARM or THUMB function. Add a new ebl function to mask off such bits and turn a function value into a function address so that we get the actual value that a function symbol or return address points to. It isn't easily possible to reuse the existing ebl_resolve_sym_value for this purpose, so we end up with another hook that can be used from dwfl_module_getsym, handle_cfi and elflint. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* backends: Add ebl_check_reloc_target_type.Mark Wielaard2014-05-196-3/+74
| | | | | | | | | And implement for arm and ia64. Both have special section types that are valid targets for a reloc. Both refer to unwind data. elflint now just calls ebl_check_reloc_target_type instead of hard coding the expected section types. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Introduce dwfl_module_getsym_info and dwfl_module_addrinfo.Mark Wielaard2013-12-206-1/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some arches like ppc64 use function descriptor values instead of function addresses causing matching of names and addresses to fail when using dwfl_module_getsym or dwfl_module_addrsym. Add ebl hook to resolve any function descriptor values found in non-ET_REL modules. The new function dwfl_module_getsym_info doesn't adjust the symbol value in any way, but returns the adjusted and/or resolved address associated with the symbol separately. The new function dwfl_module_addrinfo resolves against both the address associated with the symbol (which could be the function entry address) value and the adjusted st_value. So that it is easy to resolve and match either function descriptors and/or function entry addresses. Since these new functions also return more information they replace the dwfl_module_getsym_elf and dwfl_module_addrsym_elf functions that never made it into a released elfutils version. addr2line and readelf now use the new functions when looking up functions names. addr2line will now also display the section the address was found in when given -x. Extra testcases were added for both addr2line and the dwflsyms testscase. Signed-off-by: Mark Wielaard <mjw@redhat.com>