aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)Author
2018-10-12Support copy relocations in .data.rel.roKyle Russell
binutils-2.28 (17026142ef35b62ac88bfe517b4160614902cb28) adds support for copying read-only dynamic symbols into .data.rel.ro instead of .bss since .bss is technically writable. This causes prelink to error out on any binary containing COPY relocations in .data.rel.ro. Read-only variables defined in shared libraries should be copied directly into the space allocated for them in .data.rel.ro by the linker. To achieve this, we determine whether either of the two sections containing copy relocations is .data.rel.ro. If so, we relocate the symbol memory directly into the existing section instead of constructing a new .(s)dynbss section once prelink_build_conflicts() returns. Fixes cxx1.sh, cxx2.sh, and cxx3.sh on Fedora 28 (which uses binutils-2.29). Signed-off-by: Kyle Russell <bkylerussell@gmail.com> DCO for Kyle added per email on YP list. Added ChangeLog entry. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2018-10-12rtld: get machine from undef_map for protected symbolsKyle Russell
Avoids rtld segfault when _dl_lookup_symbol_x is called with NULL for skip_map on a protected symbol relocation. Global protected symbols may not actually require a copy relocaton, in which case skip_map is undefined, so use the undef_map to determine the symbol arch. Signed-off-by: Kyle Russell <bkylerussell@gmail.com> DCO for Kyle added per email on YP list. Added ChangeLog entry. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2018-08-29prelink: Add RISC-V supportKhem Raj
2018-08-29 Khem Raj <raj.khem@gmail.com> * src/elf.h: Add RISC-V defines * src/rtld/dl-tls.c: Add RISC-V support * src/rtld/rtld.c: Add RISC-V support Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2018-08-29src/dso.c: use ehdr.e_shstrndx as indexRobert Yang
According to struct elf32_hd, the e_shnum is section header number, and the index is e_shstrndx, not e_shnum. This can fix segmention fault when handle libqb.so.0.18.2 from libqb_1.0.3. It fails to handle libqb.so.0.18.2 and get errors: Symbol section index outside of section numbers Then segmentation fault, this is because the e_shnum is 34, while e_shstrndx is 27 (it would be 33 when no errors), I've checked several elf files to confirm that the ones after e_shstrndx is NULL, so use e_shstrndx should be correct. Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2017-06-20Fix x32 layout1 test.Andrew Stubbs
The layout1 test case currently fails for x32 because there is insufficient address space for all the libraries. There's two ways to fix this: 1. Increase mmap_end such that there's more space. 2. Reduce max_page_size so that less space is wasted. I'm not sure what the implications of option 2 would be, so the attached patch implements option 1. This still limits the number of possible libraries somewhat severely, but it's more than enough to pass the layout1 test. Andrew 2016-12-16 Andrew Stubbs <ams@codesourcery.com> * src/arch-x86_64.c (PL_ARCH(x32)): Set mmap_end to 0x60000000.
2017-06-20Fix ifunc on x86_64 x32Andrew Stubbs
The ifunc1, ifunc2, and ifunc3 tests currently fail on x86_64 x32 ABI because the testcase crashes at runtime. The testcases run fine when not prelinked. In the case of ifunc1, the test tries to call the "lib2t2" function directly, instead of using it as an indirect call, which leads to the testcase aborting. In real code this would not cause an immediate crash, but presumably would lead to undefined behaviour. The attached patch fixes the problem by converting R_X86_64_32 conflict relocations to R_X86_64_IRELATIVE (in the same way as R_X86_64_64 relocations are). I've tested this with the cross_prelink branch and a suitably configured cross-toolchain. I expect it would be fine on the master branch also, but I can't test that. Andrew Stubbs Mentor Graphics/CodeSourcery 2016-12-09 Andrew Stubbs <ams@codesourcery.com> * src/arch-x86_64.c (x86_64_prelink_conflict_rela): Also convert R_X86_64_32 conflicts to R_X86_64_IRELATIVE for ifuncs. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2017-06-20Support x32 libx32 directoryJoseph Myers
Cross-prelink's prelink-rtld is missing suport for the /libx32 directory used with the x86_64 x32 ABI. This patch adds such support. 2016-09-14 Joseph Myers <joseph@codesourcery.com> * src/rtld/rtld.c (load_ld_so_conf): Add argument use_x32. (main): Update call to load_ld_so_conf. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2017-06-20rtld: Add missing DT_NEEDED DSOs to needed_listKyle Russell
prelink-rtld may report an "error while loading shared libraries" for the wrong library. If some set of DT_NEEDED DSOs are not in the default search path, they may have a dso_list entry added, but no matching entry is added to the needed_list. This causes the linker to miscalculate the max number of dsos during build_local_scope(), which later causes find_needed() to not search the entire l_local_scope[0]->r_list during _dl_check_map_versions() (since the max from build_local_scope() becomes l_local_scope[0]->r_nlist). Since find_needed() searches through the r_list, which would have the dso_list entries for the libraries that weren't found earlier, this cuts the search short, meaning libraries near the end of the local scope don't get included in the map version search. As the comment in _dl_check_map_versions() suggests, if needed is NULL, that means a dependency was not found and no stub entry created, which should never happen. Signed-off-by: Kyle Russell <bkylerussell@gmail.com> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2017-06-20src/rtld: Add MicroBlaze support based on glibc-2.24Nathan Rossi
Add definitions/config to support MicroBlaze, using glibc-2.24 as reference. Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> Added ChangeLog entry. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-08-17src/rtld/dl-open.c: Change to work with older compilersMark Hatle
2016-08-17 Mark Hatle <mark.hatle@windriver.com> * src/rtld/dl-open.c: Change to work with older compilers Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-06-03Fix prelink section ordering on subsequent prelinkDave Lerner
Some linkers create a binary which has a section header table that is not in section header offset order. However, as noted in check_dso(), several routines in prelink and in libelf-0.7.0 too rely on sh_offsets monotonically increasing, and if that fails then prelink quits. But the check is only on dso's, not binaries. For binaries, fdopen_dso() reorders the section headers to section header offset order prior to work on the section data, so that the new prelinked binary is written in section order. However, on subsequent prelinks of a prelinked binary, the prelink_exec() works on the undone section, not the fdopen_dso() reordered sections, and may construct a section header table with section orders different than the first prelink of the binary. The function below tests for that case and resets the section header order to the offset order by enforcing the binutils linker change: 'The net effect is .shstrab section is now placed after .symtab and .strtab sections'. See binutils-gdb.git commit 3e19fb8f990e4c. Signed-off-by: Dave Lerner <dave.lerner@windriver.com> 2016-06-03 Dave Lerner <dave.lerner@windriver.com> * src/exec.c: New check_reorder_needed, section_reorder_fix functions Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-03-22Fix LD_PRELOAD w/o rtld caseMark Hatle
2016-03-22 Mark Hatle <mark.hatle@windriver.com> * src/gather.c, src/get.c: Fix LD_PRELOAD Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-03-22Fix prelink-rtld depth-first search, should be breadth firstMark Hatle
2016-03-18 Donn Seeley <donn.seeley@windriver.com> * src/rtld/rtld.c: rewrite build_local_scope to ensure breadth-first processing * testsuite/order: Add test to verify prelink/prelink-rtld resolution order This problem was causing a conflict in the Yocto Project between 'fork' from libc and libpthread. See Yocto Project bug 9131. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-03-22Fix compilation warningsMark Hatle
2016-03-18 Mark Hatle <mark.hatle@windriver.com> * src/rtld/rtld.h, src/dso.c: Fix compilation warning Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-03-22src/rtld: Add ability to debug scopeMark Hatle
2016-03-18 Mark Hatle <mark.hatle@windriver.com> * dl-open.c, rtld.h, Makefile.am: Add _dl_show_scope function * rtld.c: Use _dl_show_scope if RTLD_DEBUG=scopes defined Generate a scope for the exectuable Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-03-22rtld/dl-load.c: Fix segfault on uninitialized DSOMark Hatle
2016-03-10 Mark Hatle <mark.hatle@windriver.com> * dl-load.c: Fix segfault on empty dso entry Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-03-22rtld: Resync to glibc-2.23Mark Hatle
2016-03-10 Mark Hatle <mark.hatle@windriver.com> * rtld/: Rsync to glibc-2.23 (no functional changes) Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2016-03-22configure.ac/makefile.am: Update to newer autoconf/automake formatMark Hatle
Resolves an issue: configure.ac:8: warning: AM_INIT_AUTOMAKE: two- and three-arguments change based on a patch from Vaneet Narang <v.narang@samsung.com> and Maninder Singh <maninder1.s@samsung.com> Add AC_CONFIG_MACRO_DIR([m4]) to configure.ac to resolve warning. Quote AC_LIBELF_SXWORD in m4/libelf.m4 to resolve: warning: underquoted definition of AC_LIBELF_SXWORD in m4/libelf.m4 In Makefile.am files, replace INCLUDES w/ AM_CPPFLAGS as appropriate. Remove 'AUTOMAKE_OPTIONS = 1.4 gnu', no longer necessary. 2016-03-10 Mark Hatle <mark.hatle@windriver.com> * configure.ac, m4/libelf.m4, doc/Makefile.am, gelf/Makefile.am, gelfx/Makefile.am, gelfx32/Makefile.am, patches/Makefile.am, src/Makefile.am, src/rtld/Makefile.am, testsuite/Makefile.am: Update to avoid autoconf/automake warnings Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2015-10-29Fix ARM IFUNC support20151030_crossMark Hatle
In the original ARM IFUNC support, it appears a small chunk of code in the arm_prelink_conflict_rela function was missed. This commit adds the missing code from the original work. See: https://bugzilla.redhat.com/show_bug.cgi?id=1009601 2015-10-29 Mark Hatle <mark.hatle@windriver.com> Kyle McMartin <kmcmartin@redhat.com> Jakub Jelinek <jakub@redhat.com> Julian Brown <julian@codesourcery.com> * testsuite/ifunc.h: Fix missing # * src/arch-arm.c (arm_prelink_conflict_rela): Add missing hunk that implemented R_ARM_IRELATIVE, and ifunc conflicts. See: https://bugzilla.redhat.com/show_bug.cgi?id=1009601 Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2015-10-29prelink: Fix MIPS section header checkMark Hatle
MIPS has added a new SHT_MIPS_ABIFLAGS section, which the prelinker did not know it could skip. Add this to the list of items to be OK to skip. 2015-10-29 Mark Hatle <mark.hatle@windriver.com> * prelink.h: Define SHT_MIPS_ABIFLAGS if not set * prelink.c: OK to skip SHT_MIPS_ABIFLAGS optimize the loop to stop on the first bad entry adjust the error to give us more info on the bad section Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2015-10-28src/get.c: Sync the rtld and prelinker to the same defineMark Hatle
No actual change in the defined value occurs, but the format on both sides of the interface (rtld and prelinker) are now using the same define. 2015-10-28 Mark Hatle <mark.hatle@windriver.com> * get.c: Sync rtld/prelink type_class values Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2015-10-28rtld: Fix the prelink-rtld to use the same method as ld.soMark Hatle
2015-10-28 Mark Hatle <mark.hatle@windriver.com> * dl-lookupX.h: Sync with glibc fix for ld.so / prelink mismatch 2015-10-28 H.J. Lu <hongjiu.lu@intel.com> [BZ #19178] * elf/dl-lookup.c (RTYPE_CLASS_VALID): New. (RTYPE_CLASS_PLT): Likewise. (RTYPE_CLASS_COPY): Likewise. (RTYPE_CLASS_TLS): Likewise. (_dl_debug_bindings): Use RTYPE_CLASS_TLS and RTYPE_CLASS_VALID to set relocation type class for DL_DEBUG_PRELINK. Clear the ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA bit for DL_DEBUG_PRELINK. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2015-10-28Upstream prelink project appears abandoned, take over the projectMark Hatle
The upstream project appears to be dead now. So switch to a more git friendly directory, no reason to maintain the SVN trunk any longer. 2015-10-22 Mark Hatle <mark.hatle@windriver.com> * Upstream project appears to have been abandoned * Update the project to remove the SVN like 'trunk' dir * Adjust the AUTHORS file * Move the README.cross to replace README and update it * Move the previous ChangeLog to ChangeLog.1 * Move the current ChangeLog.cross to ChangeLog Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2006-07-21Move code into trunk subdirectory.drow
git-svn-id: http://sourceware.org/svn/prelink@134 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820060712prelink_20060712jakub
git-svn-id: http://sourceware.org/svn/prelink@132 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820060621jakub
git-svn-id: http://sourceware.org/svn/prelink@131 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820060522jakub
git-svn-id: http://sourceware.org/svn/prelink@130 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820050901jakub
git-svn-id: http://sourceware.org/svn/prelink@127 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820050729jakub
git-svn-id: http://sourceware.org/svn/prelink@126 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820050610jakub
git-svn-id: http://sourceware.org/svn/prelink@125 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820050314jakub
git-svn-id: http://sourceware.org/svn/prelink@124 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820050207jakub
git-svn-id: http://sourceware.org/svn/prelink@123 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820041123jakub
git-svn-id: http://sourceware.org/svn/prelink@122 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820041012jakub
git-svn-id: http://sourceware.org/svn/prelink@121 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820041002jakub
git-svn-id: http://sourceware.org/svn/prelink@120 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820041001jakub
git-svn-id: http://sourceware.org/svn/prelink@119 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040931jakub
git-svn-id: http://sourceware.org/svn/prelink@118 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040929jakub
git-svn-id: http://sourceware.org/svn/prelink@117 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040908jakub
git-svn-id: http://sourceware.org/svn/prelink@116 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040907jakub
git-svn-id: http://sourceware.org/svn/prelink@115 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040520jakub
git-svn-id: http://sourceware.org/svn/prelink@113 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040516jakub
git-svn-id: http://sourceware.org/svn/prelink@112 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040514jakub
git-svn-id: http://sourceware.org/svn/prelink@111 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040505jakub
git-svn-id: http://sourceware.org/svn/prelink@110 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040317jakub
git-svn-id: http://sourceware.org/svn/prelink@109 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040304jakub
git-svn-id: http://sourceware.org/svn/prelink@108 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040216jakub
git-svn-id: http://sourceware.org/svn/prelink@107 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040129jakub
git-svn-id: http://sourceware.org/svn/prelink@106 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040127jakub
git-svn-id: http://sourceware.org/svn/prelink@105 94c539fb-cf18-0410-b60f-edeeb537fa16
2006-07-1820040115jakub
git-svn-id: http://sourceware.org/svn/prelink@104 94c539fb-cf18-0410-b60f-edeeb537fa16