summaryrefslogtreecommitdiffstats
path: root/libelf
Commit message (Collapse)AuthorAgeFilesLines
* Split the "selfcontained" configure option in twoHEADQtCreator4.15.1QtCreator4.15.0-rc1QtCreator4.15.0-beta2QtCreator4.15.0-beta1QtCreator4.15.0QtCreator4.14.2QtCreator4.14.1QtCreator4.14.0-rc1QtCreator4.14.0-beta2QtCreator4.14.0-beta1QtCreator4.14.0QtCreator4.13.3QtCreator4.13.2QtCreator4.13.1QtCreator4.13.0-rc1QtCreator4.13.0-beta2QtCreator4.13.0-beta1QtCreator4.13.0QtCreator4.12.4QtCreator4.12.3QtCreator4.12.2QtCreator4.12.1QtCreator4.12.0-rc1QtCreator4.12.0-beta2QtCreator4.12.0-beta1QtCreator4.12.0QtCreator4.11.2QtCreator4.11.0-rc1QtCreator4.11.0-beta2QtCreator4.11.0-beta1QtCreator4.11.0master5.04.154.144.134.124.1112.011.010.0Ulf Hermann2019-08-261-10/+10
| | | | | | | | upstream is growing an option to install elf.h. We want to use that. Change-Id: Ica5bf0cdf281eb17ef29e0e1029662a5a9d875b1 Reviewed-by: Christian Kandeler <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Use file-based ELF update strategy if posix_fallocate is absentUlf Hermann2019-01-181-2/+2
| | | | | | | | | | | | | | The whole idea of extending the file and the mmap in place is rather fragile and only works on rather specific setups. If we can't even extend the file, we will likely not be able to extend the mapping that refers to it, either. In that case we might still be able to write the formally undefined memory behind the end of the file because the OS actually maps whole pages, but that is an unspeakable horror. The file based strategy is slower, but robust. Change-Id: I995a173d60cfd70dde08ff78b7a97182e83b4727 Reviewed-by: Christian Kandeler <[email protected]>
* Merge tag 'elfutils-0.175'Ulf Hermann2019-01-0912-53/+206
|\ | | | | | | | | | | elfutils 0.175 release Change-Id: I409f41767af349d0521351dd733879ad31c65aab
| * libelf: Mark both fsize and msize with const attribute.Mark Wielaard2018-11-162-2/+7
| | | | | | | | | | | | | | | | | | | | GCC9 -Wmissing-attributes pointed out that although we alias the fsize and msize functions only fsize was marked as const. Fix by also marking the msize definition as const. https://sourceware.org/bugzilla/show_bug.cgi?id=23884 Signed-off-by: Mark Wielaard <[email protected]>
| * libelf: Correctly setup alignment of SHF_COMPRESSED section data.Mark Wielaard2018-11-133-4/+17
| | | | | | | | | | | | | | | | | | | | | | We didn't set the alignment of SHF_COMPRESSED sections correctly. Those sections start with an Elf(32|64)_Chdr. Make sure sh_addralign is setup to be able to read such a struct directly. Likewise don't trust the alignment set on any SHF_COMPRESSED section, but always make the (raw) compressed data aligned correctly for the reading the Elf(32|64)_Chdr directly. Signed-off-by: Mark Wielaard <[email protected]>
| * strip: Also handle gnu compressed debug sections with --reloc-debug-sectionsMark Wielaard2018-11-132-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Check whether a section was gnu compressed and decompress it first before trying to resolve relocations. Recompress it afterwards. This found a bug in elf_compress_gnu which would use the "raw" file contents even if the user had just created the section (copying over the section from the original input file). Add compressed ET_REL tests to run-strip-reloc.sh testcase. Signed-off-by: Mark Wielaard <[email protected]>
| * Handle GNU Build Attribute ELF Notes.Mark Wielaard2018-11-132-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * libelf: Explicitly update section data after (de)compression.Mark Wielaard2018-11-093-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to explictly trigger a section data reload after updating the ELF section rawdata to make sure it gets written out to disk on an elf_update. Doing this showed one bug/inefficiently when the underlying file has a different endianness. In that case for debug sections we would convert by allocating a new buffer and just copying over the raw data into a new buffer. This is not really necessary and would hide any relocations done on the rawdata by libdwfl. Added a couple of new ppc64 big endian testfiles that show the issue. Signed-off-by: Mark Wielaard <[email protected]>
| * Recognize and parse GNU Property notes.Mark Wielaard2018-10-2911-43/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* | Merge tag 'elfutils-0.174'Ulf Hermann2018-10-116-18/+100
|\| | | | | | | | | | | elfutils 0.174 release Change-Id: Ibcbdfca61cf0b65391ab6d0ad00f18ba61027e07
| * libelf: Fix shnum and section zero handling.Mark Wielaard2018-09-133-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For ELF files with more than SHN_LOWRESERVE sections we always need section zero to store the section number (it doesn't just fit in the Ehdr e_shnum field). Make sure to create it if it doesn't exist yet in elf_getscn. Also fix handling on shnum in updatefile for the mmap case (we already got this correct for the non-mmap case). This adds a new test run-copymany-sections.sh which is like run-copyadd-sections.sh but tries to add two times 65535 sections. It makes sure libelf can copy the whole file and elfcmp checks they are the same. It doesn't use mmap for addsections since that doesn't work yet. ELF_C_RDWR_MMAP needs mremap which will fail since it needs too much space and the original mmap cannot move. Signed-off-by: Mark Wielaard <[email protected]>
| * libelf: Fix some issues with ELF_C_RDWR_MMAP.Mark Wielaard2018-09-133-11/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When ELF_C_RDWR_MMAP is used libelf might have to write overlapping memory when moving the section data or headers. Make sure to use memmove, not memcpy. Also the size of the underlying file might have to change. That means we will have to also extend the mmap region with mremap. Since we are using direct pointers into the mmapped area we cannot move the mmap, only extend it. This might still fail if there is not enough free memory available to extend the mmap region. Two new test programs have been added. elfcopy which copies a whole elf file (using either ELF_C_WRITE or ELF_C_WRITE_MMAP). And addsections which adds new sections to an existing ELF file (using either ELF_C_RDWR or ELF_C_RDWR_MMAP). The newly added test will fail under valgrind without the fixes. Signed-off-by: Mark Wielaard <[email protected]>
| * libelf: Return error if elf_compress_gnu is used on SHF_COMPRESSED section.Mark Wielaard2018-08-183-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | Compressing a section that is already compressed is fine, but useless. But it isn't possible to gnu compress (or decompress) a SHF_COMPRESSED section since there is no state kept that would tell if the section was first GNU compressed or first gabi compressed. Calling elf_compress_gnu on a section and then calling elf_compress on it to decompress it twice could cause a crash (the other way around is fine). Just disallow it. https://sourceware.org/bugzilla/show_bug.cgi?id=23528 Signed-off-by: Mark Wielaard <[email protected]>
| * libelf: Fix documentation of elf_getshdrstrndx and elf_getshstrndx.Mark Wielaard2018-07-272-4/+9
| | | | | | | | | | | | | | | | | | Because of copy/paste error part of the documentation for elf_getshdrstrndx and elf_getshstrndx was actually for elf_getshdrnum and elf_getshnum. Fix it to refer to the proper ehdr field and deprecated function name. Signed-off-by: Mark Wielaard <[email protected]>
* | Don't install versioned DLLs on windowsUlf Hermann2018-07-241-11/+15
| | | | | | | | | | | | | | | | Nobody can use those, and as windows doesn't have proper symlinks, they take up lots of space. Change-Id: If62db984c7ac62e798a88e3a4ecd15962683d001 Reviewed-by: Christian Kandeler <[email protected]>
* | Merge tag 'elfutils-0.173'Ulf Hermann2018-07-1310-50/+369
|\| | | | | | | | | | | elfutils 0.173 release Change-Id: I83dc56dd15c26fe7acf4ce73c29df65b8b65e757
| * libelf: Don't return unaligned data returned from elf_getdata[_rawchunk].Mark Wielaard2018-06-224-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For i386 and x86_64 we allow some unaligned data accesses. We also return unaligned data from elf_getdata[_rawchunk]. But that might go wrong if we then access the ELF types inside. When build with gcc -O3 for example the compiler might vectorize loops accessing ELF words or types. The instructions used do require the data is naturally aligned. If the function returnes unaligned data the program will segfault and crash. This happens for example with the code in dwfl_module_getdwarf.c that tries to iterate over the hash buckets gotten through elf_getdata_rawchunk based on the DT_[GNU]_HASH value. This only happens when the underlying ELF file is mmapped, and it is meant as optimization so that we don't have to copy data first so that it is correctly aligned. In most cases the data is already naturally aligned though. But it might not be for non-native ELF files. Given that it might even happen in our own code base and these are public functions that can be used by code that might rely on the data returned being correctly aligned for the ELF data type requested just always return correctly aligned data. Signed-off-by: Mark Wielaard <[email protected]>
| * libelf: Sync elf.h from glibc.Mark Wielaard2018-06-212-1/+8
| | | | | | | | | | | | Add NT_PPC_PKEY, R_BPF_64_64 and R_BPF_64_32. Remove R_BPF_MAP_FD. Signed-off-by: Mark Wielaard <[email protected]>
| * libelf: Sync elf.h from glibcAndreas Schwab2018-04-232-12/+63
| | | | | | | | Signed-off-by: Andreas Schwab <[email protected]>
| * libelf: Sync elf.h from glibc.Mark Wielaard2018-02-172-2/+98
| | | | | | | | Signed-off-by: Mark Wielaard <[email protected]>
| * Use fallthrough attribute.Joshua Watt2018-02-104-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * libelf: Don't error out when sanity checking e_shoff if scncnt is zero.Mark Wielaard2017-10-132-2/+7
| | | | | | | | | | | | | | | | We won't use the e_shoff value in that case because we will set elf->state.elf[64|32].scns.cnt to zero to indicate not to read any section header data from the file. Signed-off-by: Mark Wielaard <[email protected]>
| * libelf: Add ELF_E_INVALID_ELF error value.Mark Wielaard2017-10-135-23/+78
| | | | | | | | | | | | | | | | Add ELF_E_INVALID_ELF which is set when the ELF file data is bad. This is different from ELF_E_INVALID_FILE which is set when the file could not be read. Signed-off-by: Mark Wielaard <[email protected]>
| * Make sure packed structs follow the gcc memory layoutUlf Hermann2017-09-202-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc defaults to using struct layouts that follow the native conventions, even if __attribute__((packed)) is given. In order to get the layout we expect, we need to tell gcc to always use the gcc struct layout, at least for packed structs. To do this, we can use the gcc_struct attribute. This is important, not only for porting to windows, but also potentially for other platforms, as the bugs resulting from struct layout differences are rather subtle and hard to find. Signed-off-by: Ulf Hermann <[email protected]>
| * Check if gcc complains about __attribute__ (visibility(..))Ulf Hermann2017-08-182-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If so, define attribute_hidden to be empty. Also, use attribute_hidden in all places where we hide symbols. If this attribute is missing, it simply means that we cannot hide private symbols in the binary using attributes. This disables some optimizations and may increase the risk of symbol name clashes with other libraries, but is not fatal. However, we still employ linker version scripts to explicitly define the exported symbols. This serves much of the same purpose. Also, as all our symbols are prefixed with the library name, and "__" for private ones, the chance of clashes is low anyway. Signed-off-by: Ulf Hermann <[email protected]>
| * Check for -z,defs, -z,relro, -fPIC, -fPIE before using themUlf Hermann2017-08-182-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * libelf: Sync elf.h from glibc.Mark Wielaard2017-08-152-3/+97
| | | | | | | | | | | | Add new powerpc note descriptors. Signed-off-by: Mark Wielaard <[email protected]>
* | Merge tag 'elfutils-0.170'Ulf Hermann2017-08-173-5/+22
|\| | | | | | | | | | | 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 <[email protected]>
| * Unify linking of libasm, libelf, libdw, backendsUlf Hermann2017-07-242-5/+17
| | | | | | | | | | | | | | | | | | | | Link them all with -z,defs,-z,relro,--no-undefined, provide complete dependencies for the link steps, and add libeu.a to each one. libeu.a contains useful library functionality that each of them might use. The linker will strip unneeded symbols, so linking it in won't hurt even if none of the functions are used. Signed-off-by: Ulf Hermann <[email protected]>
* | Merge tag 'elfutils-0.169'QtCreator4.5.1QtCreator4.5.0-rc1QtCreator4.5.0QtCreator4.4.1QtCreator4.4.0-rc1QtCreator4.4.0-beta1QtCreator4.4.04.54.4Ulf Hermann2017-05-082-5/+9
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: ChangeLog backends/ChangeLog config/ChangeLog lib/ChangeLog libasm/ChangeLog libcpu/ChangeLog libdw/ChangeLog libdwfl/ChangeLog libdwfl/derelocate.c libdwfl/linux-kernel-modules.c libebl/ChangeLog libelf/ChangeLog src/ChangeLog tests/ChangeLog Change-Id: I3b7ced947c6498290aaae27443985b84531f0bcd
| * Avoid double-including config.hUlf Hermann2017-05-022-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through our own private headers. In order to set a clear rule about inclusion of config.h, it is now included in every .c file as first header, but not in any header. This will definitely avoid double-inclusion and satisfy the condition that it has to be included before gnulib headers. It comes at the price of adding some redundancy, but there is no clean way to avoid this. Signed-off-by: Ulf Hermann <[email protected]>
| * Use F_GETFD rather than F_GETFL to check validity of file descriptorUlf Hermann2017-05-022-1/+5
| | | | | | | | | | | | | | F_GETFD is both cheaper and easier to port, and otherwise has the same effect here. Signed-off-by: Ulf Hermann <[email protected]>
| * Make __attribute__ conditional in all installed headersUlf Hermann2017-05-022-7/+36
| | | | | | | | | | | | | | | | | | | | __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 <[email protected]>
| * On elf_update, remember when we mmap()Ulf Hermann2017-04-282-0/+6
| | | | | | | | | | | | Otherwise we skip the munmap() later. This leaks resources. Signed-off-by: Ulf Hermann <[email protected]>
| * libelf: Initialize n to zero in elf_getarsym.Mark Wielaard2017-04-192-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | When building with gcc -Os it seems we can inline read_number_entries but if that function fails then n will not be initialized. GCC seems not to realize that in that case n won't be used at all. Explicitly initialize n to zero to prevent a spurious error: 'n' may be used uninitialized in this function [-Werror=maybe-uninitialized] in that case. https://sourceware.org/bugzilla/show_bug.cgi?id=21011 Signed-off-by: Mark Wielaard <[email protected]>
* | Open files in O_BINARYUlf Hermann2017-05-082-1/+5
| | | | | | | | | | | | | | | | | | If O_BINARY is not defined, define it to 0, so that the change has no effect then. Some systems have separate binary and text modes for files, and we don't want the text mode to be used. Change-Id: If7efb5bd448c2a1c7d1eb5dab276849b1b15a3ce Reviewed-by: Christian Kandeler <[email protected]>
* | Skip fchown, fchmod, fadvise, fallocate if functions are unavailableUlf Hermann2017-05-042-0/+9
| | | | | | | | | | | | | | | | | | | | | | If fchmod or fchown are unavailable, then the file permission model is likely to be different from what we expect there. posix_fallocate is a rather fragile affair already on linux, and not guaranteed to do anything useful. If it's not available, the result will be the same as when it's available and unreliable. fadvise is an optimization. Change-Id: I28a77e976a0198cf80397b45eb1bc8cfb30664f5 Reviewed-by: Christian Kandeler <[email protected]>
* | Add a "selfcontained" mode to provide missing headers on windowsUlf Hermann2017-05-021-1/+8
| | | | | | | | | | | | | | | | | | | | | | On windows there is no features.h, uid_t, gid_t, mode_t, and pid_t are not defined and there is also no elf.h. To make it possible to build other software against libelf and libdw, install our own version of elf.h, and a bare-bones features.h that provides exactly the above declarations. Change-Id: I9df3c8cbffe431b8b6834dbd2246e38df4f5e172 Reviewed-by: Christian Kandeler <[email protected]>
* | Drop __BEGIN_DECLS and __END_DECLS from elf.hUlf Hermann2017-05-021-3/+7
| | | | | | | | | | | | | | | | We don't use those anywhere else. Also, put the 'extern "C"' after the included headers. Change-Id: I3b9fd0d86f148ac770e9335eeb873e8bc7cbb60b Reviewed-by: Christian Kandeler <[email protected]>
* | Make sure packed structs follow the gcc memory layoutUlf Hermann2017-05-021-1/+1
| | | | | | | | | | | | | | | | On windows gcc by default generates code that follows the MSVC layout. We don't want that as it adds extra padding. Change-Id: I92efe5da2a2ad818783707ee96a9b8e0eb606dbd Reviewed-by: Christian Kandeler <[email protected]>
* | Generate .lib files on PE platformsUlf Hermann2017-05-021-3/+24
| | | | | | | | | | | | | | MSVC needs them to link against .dll files. Change-Id: Iaf15391d28e0cd3292903dda2cd74b8b99a94274 Reviewed-by: Christian Kandeler <[email protected]>
* | Generalize library namesUlf Hermann2017-04-282-14/+17
| | | | | | | | | | | | | | | | | | 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 <[email protected]>
* | Check if we need -lintl for linking gettextUlf Hermann2017-04-281-1/+1
| | | | | | | | | | | | | | | | We might not have gettext available from libc and we cannot get it from gnulib either. Change-Id: I1cc657b13b97bcc7c0f158f11b6702c24e69695c Reviewed-by: Christian Kandeler <[email protected]>
* | Check if gcc complains about __attribute__ (visibility(..))Ulf Hermann2017-04-282-1/+5
| | | | | | | | | | | | | | | | If so, define attribute_hidden to be empty. Also, use attribute_hidden in all places where we hide symbols. Change-Id: I37353459710dbbd1c6c6c46110514fc18515c814 Reviewed-by: Christian Kandeler <[email protected]>
* | Check for -z,defs, -z,relro, -fPIC, -fPIE before using themUlf Hermann2017-04-282-3/+7
| | | | | | | | | | | | | | | | | | 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 <[email protected]>
* | Drop handrolled or #ifdef'ed libc replacementsUlf Hermann2017-04-283-19/+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 <[email protected]>
* | Add gnulib modules to replace missing libc functionalityUlf Hermann2017-04-272-0/+7
| | | | | | | | | | | | | | | | | | | | This enables us to build a fully featured elfutils package on systems with reduced C libraries, such as windows. All the modules are built into libgnu.a, which is then linked into all binaries if --enable-gnulib is given on the configure line. Change-Id: I743fd22172bc85d9f10dcc3dad8eb921f462b554 Reviewed-by: Christian Kandeler <[email protected]>
* | On elf_update, remember when we mmap()Ulf Hermann2017-04-262-0/+6
| | | | | | | | | | | | | | Otherwise we skip the munmap() later. This leaks resources. Change-Id: I9e04ea3f0a608e88c474379df19c41261ecd092e Reviewed-by: Christian Kandeler <[email protected]>
* | Avoid double-including config.hUlf Hermann2017-04-262-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through our own private headers. In order to set a clear rule about inclusion of config.h, it is now included in every .c file as first header, but not in any header. This will definitely avoid double-inclusion and satisfy the condition that it has to be included before gnulib headers. It comes at the price of adding some redundancy, but there is no clean way to avoid this. Change-Id: Ib78dd7e058ef8ac93cd379dcd14a2ffbc86c1988 Reviewed-by: Christian Kandeler <[email protected]>