Commit graph

401 commits

Author SHA1 Message Date
Du Chenyang
865119efd4 Temporarily disable text relocation warnings for x86 libraries
Too many such warnings will cause CTS failed. This issue still exists
in some x86 version libraries: libdvm.so/libart.so.

$scanelf -qT out/target/product/generic_x86/system/lib/libdvm.so
  libdvm.so: (memory/data?) [0x2BAC7] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8]
  libdvm.so: (memory/data?) [0x2BB98] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8]
  libdvm.so: (memory/data?) [0x2EB28] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8]
  libdvm.so: (memory/data?) [0x2EF87] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]
  libdvm.so: (memory/data?) [0x2EFAF] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]
  libdvm.so: (memory/data?) [0x2EFD7] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]
  libdvm.so: (memory/data?) [0x2EFFF] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]
  libdvm.so: (memory/data?) [0x2F027] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]

Bug: https://code.google.com/p/android/issues/detail?id=68431
Change-Id: I11ecac282f1163e49a82156fce2a76cc2d619960
2014-04-18 16:00:55 -07:00
Elliott Hughes
88b44feb7d Remove duplicate line in linker/Android.mk.
Change-Id: I7b4d5fcdfacc840bbda4ffd965e5315c4651cfe5
2014-04-01 11:41:36 -07:00
Christopher Ferris
c19972a4ca Merge "Use __unused instead of UNUSED in linker.cpp" 2014-03-30 22:24:22 +00:00
Colin Cross
406a75d371 linker: use LOCAL_MULTILIB := both style to build linker64
Use LOCAL_MODULE_STEM_32 and LOCAL_MODULE_STEM_64 to build
linker and linker64.  Set LOCAL_MULTILIB := both for consistency
with other rules of this type, although LOCAL_MULTILIB := both is
only consumed by executable.mk which is skipped by
linker_executable.mk.  Duplicate the necessary new parts of
executable.mk.

Change-Id: I888e87cf125cfbcfdee6a55b6377d8bc5ce402ea
2014-03-27 10:45:57 -07:00
Kito Cheng
812fd4263a Use __unused instead of UNUSED in linker.cpp
- sys/cdefs.h already define __unused, just use it
   instead of define a local one.

Change-Id: Iacf3da9193e65e1f34b12760b28bcb64b67cb790
2014-03-25 22:54:19 +08:00
Elliott Hughes
851e68a240 Unify our assembler macros.
Our <machine/asm.h> files were modified from upstream, to the extent
that no architecture was actually using the upstream ENTRY or END macros,
assuming that architecture even had such a macro upstream. This patch moves
everyone to the same macros, with just a few tweaks remaining in the
<machine/asm.h> files, which no one should now use directly.

I've removed most of the unused cruft from the <machine/asm.h> files, though
there's still rather a lot in the mips/mips64 ones.

Bug: 12229603
Change-Id: I2fff287dc571ac1087abe9070362fb9420d85d6d
2014-02-20 13:51:26 -08:00
Benjamin Adolphi
006f9ad891 Linker writes to wrong memory location when processing DT_MIPS_RLD_MAP
When bionic's dynamic linker processes the .dynamic section of a MIPS ELF binary and encounters the DT_MIPS_RLD_MAP dynamic array tag, it calculates the address of where to write a pointer to the _r_debug structure. The current implementation simply reads the value given in the d_ptr field and writes the pointer address to that location. However, this value has to be adjusted to reflect the real load address of the binary. Otherwise the linker will write to a faulty location possibly resulting in a crash when linking a MIPS binary that includes DT_MIPS_RLD_MAP. This change corrects that problem.

Change-Id: I1a91874f7ab47289001fe72d9016660c14c70362
Signed-off-by: Benjamin Adolphi <b.adolphi@gmail.com>
2014-02-19 00:50:32 +01:00
Colin Cross
36ee4ab243 build linker and linker64 on 64-bit architectures
Change-Id: I400bbaf5a779fc427de4c3d86c66548b0179b10d
2014-02-13 11:18:47 -08:00
Elliott Hughes
c62b8a4d3f Remove unused variables not spotted by GCC.
Change-Id: I49a16096bc0f41f3ad0007249161e8bdfcf3438c
2014-02-12 17:17:41 -08:00
Elliott Hughes
faf05bacd4 Clean up all the lint cpplint can find in the dynamic linker.
Change-Id: Ic9ee7153817c22a252cc4b309283e355b623cab9
2014-02-11 17:33:49 -08:00
Chris Dearman
9918665a45 [MIPS64] Dynamic linker
Change-Id: I937c7c776cae3d66e214798d5217a922cd106bfc
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Duane Sand <duane.sand@imgtec.com>
2014-02-11 15:33:14 -08:00
Elliott Hughes
0266ae5f88 Switch <elf.h> over to linux uapi under the covers.
Remove the linker's reliance on BSD cruft and use the glibc-style
ElfW macro. (Other code too, but the linker contains the majority
of the code that needs to work for Elf32 and Elf64.)

All platforms need dl_iterate_phdr_static, so it doesn't make sense
to have that part of the per-architecture configuration.

Bug: 12476126
Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
2014-02-10 18:22:24 -08:00
Elliott Hughes
3a9c5d66dc Fix <link.h>.
Also move some of the stuff that should be in <link.h> out of the
private "linker.h", to make it clearer that these are public API
known to gdb that we can't change.

Bug: 12554197
Change-Id: I830e1260d3d8b833ed99bc1518f1c6b6102be8af
2014-02-10 13:31:13 -08:00
Elliott Hughes
62e9c76ee8 Clean up debugger.cpp slightly.
In particular, don't do weird things with 'int tid'.

Change-Id: I0fd9158a452967163508ada8987de9494ad5f9af
2014-01-31 17:27:00 -08:00
Elliott Hughes
f858bd1c6e LP64 binaries should talk to debuggerd64.
Change-Id: I7eb30f9d04f80b6b45d3148757970d3f1117493c
2014-01-31 16:56:39 -08:00
Weiwu Chen
5ceb889ac9 bionic: Change the type of soinfo's size to size_t
Some system functions like munmap expect soinfo's size to be size_t, but currently
it is unsigned. Change it to size_t to fit 64bit's portability.

Change-Id: I0bf6d522b38b0cd9bf1db05b004b5326217412a2
Signed-off-by: Weiwu Chen <weiwu.chen@intel.com>
Signed-off-by: Qiming Shi <qiming.shi@intel.com>
2014-01-28 11:54:01 -08:00
Qiming Shi
4041b13c20 bionic: Do not use magic number for portability
Do not use the magic number 0xFFFFFFFFU to represent the max value of an address
as it's not correct on 64bit platform. We should use UINTPTR_MAX instead.

Change-Id: I1fc6f5864a651b2eddea2333cb0788f9d9223270
Signed-off-by: Qiming Shi <qiming.shi@intel.com>
Signed-off-by: Weiwu Chen <weiwu.chen@intel.com>
2014-01-27 14:51:07 -08:00
Colin Cross
d1973ca513 bionic: rename aarch64 target to arm64
Rename aarch64 build targets to arm64.  The gcc toolchain is still
aarch64.

Change-Id: Ia92d8a50824e5329cf00fd6f4f92eae112b7f3a3
2014-01-23 18:35:39 -08:00
Elliott Hughes
a4aafd1560 Make it possible for code to query the dynamic linker's default search path.
We're not going to have init(1) set LD_LIBRARY_PATH globally on 64-bit.
This patch makes it possible for libnativehelper to set LD_LIBRARY_PATH
in each Java VM (to support System.loadLibrary) without also hard-coding
the default search path there.

Change-Id: If13961fae976e06dd80d5ef522f31e8b7eb01154
2014-01-13 16:37:47 -08:00
Elliott Hughes
7ff07ad321 Add -Bsymbolic to the ld flags when linking the dynamic linker.
We don't need this on architectures other than aarch64, and
we're still investigating why we need it on aarch64, but it
doesn't seem unreasonable to have this flag set when linking
the dynamic linker anyway; it's clearly the intended behavior.

Change-Id: I4fa1b4ae543a818979934bf818eabac03bb9154f
2014-01-13 13:33:01 -08:00
Elliott Hughes
1272dbd1d7 Add NT_PRSTATUS to <elf.h>.
Needed by aarch64.

Bug: 12476126
Change-Id: I7764664459a06cf4f2a60e707bd968d321a78430
2014-01-09 15:45:07 -08:00
Elliott Hughes
54a7494f17 Regenerate the NOTICE files.
Also standardize the orthography in a few places to reduce near-duplicates
in the NOTICE files.

Change-Id: I347c75e817be61ec1b9c5b4b96226feedc8d09ab
2014-01-07 13:46:11 -08:00
Elliott Hughes
b93702a046 Improve dynamic linker diagnostics for internal errors.
If the linker can't resolve its own internal references to symbols,
we currently exit silently (albeit with EXIT_FAILURE). Not very helpful.

Change-Id: I1614fc970dee4560b38832ede1987b65a8e53a1e
2013-12-22 19:38:42 +00:00
Marcus Oakland
e365f9d654 AArch64: Linker64 support for AArch64
Addition of support for AArch64 in the linker64 target.

Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2013-12-17 15:02:43 -08:00
Pavel Chupin
5407eed84b Fix debugging issues in vdso handling
Under valgrind ehdr_vdso is null and causing segfault.
Adding debug info for vdso producing plenty of issues on debugging
through gdbserver, removing it. It doesn't seem it should be here.

Unwinding through vdso test still works.

Change-Id: I1a7e233c493f2268d725fa8d7279822d07decc49
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-12-12 11:18:46 -08:00
Sergey Melnikov
ebd506c69e Fix linker crashes during unknown symbol lookup
Integration of kernel VDSO into internal bionic data structures using
common functions.
Fix for dl_iterate_phdr function: the function provides incorrect
address of object in case of nonzero virtual and base addresses.
Location in address space of a particular program header should be
calculated using the formula:  addr = base_addr + virtual_addr.

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: Ie2ab4257fd456242aab8afed0bd5bd6b29e81d6d
2013-10-31 15:06:20 -07:00
Elliott Hughes
74ce45972d Update <sys/exec_elf.h> to get the DF_* flags.
Change-Id: Ia9e785f6b95122f94ee3b01a312db1d5bb91a72e
2013-10-28 14:59:41 -07:00
Elliott Hughes
e4d792adb8 Don't allow text relocations on 64-bit.
I've also updated our <sys/exec_elf.h> to match upstream.

Change-Id: I52f9fce3167541811208d273ff23ceaa112f7135
2013-10-28 14:34:56 -07:00
Elliott Hughes
4eeb1f12a8 Clean up linker architecture macros.
We don't need our own architecture macros; the standard ones will do.

This patch also fixes some __x86_64__ tests to be USE_RELA tests instead,
because they're not actually x86_64-specific.

I've cleaned up architecture-specific code slightly so where possible
all the code corresponding to a particular architecture is together.

This patch also fixes a bug in LP64 DT_PLTGOT handling, which should be
an error rather than falling through into DT_DEBUG! There was another #ifdef
bug where we'd only report unexpected DT_ entries on MIPS.

Change-Id: Id1d04e372611f641c1aa278a18e379f28af9eaf5
2013-10-28 11:02:49 -07:00
Elliott Hughes
60d5b06ece Simplify defining the linker architecture macro.
Like the new TODO says, though, do we need this at all? Wouldn't we be better
off just using the regular architecture-specific macros? This is a dynamic
linker, so there's never a possibility of cross-linking.

Change-Id: I7be6b8663f5e585c4024a49aae383430c86a3c1b
2013-10-24 23:18:13 -07:00
Elliott Hughes
b8b0b6b412 Revert "Don't warn about x86 text relocations. They're too prevalent."
This reverts commit 5be2c5998c.

Change-Id: I3fc8ca530cdbd74c834fb9cfabe812c9386419fc
2013-10-24 22:58:28 +00:00
Elliott Hughes
5be2c5998c Don't warn about x86 text relocations. They're too prevalent.
We should fix this (and disallow it for x86_64), but for now let's get CTS
running again.

libdvm.so and libcutils.so are the main problems.

$ scanelf -qT out/target/product/generic_x86/symbols/system/lib/libcutils.so
  libcutils.so: (memory/data?) [0x4125] in (optimized out: previous android_memset16) [0x4100]
  libcutils.so: (memory/data?) [0x424F] in (optimized out: previous android_memset16) [0x4100]
  libcutils.so: (memory/data?) [0x42F8] in (optimized out: previous android_memset16) [0x4100]
  libcutils.so: (memory/data?) [0x4349] in (optimized out: previous android_memset16) [0x4100]
  libcutils.so: (memory/data?) [0x4406] in (optimized out: previous android_memset16) [0x4100]
  libcutils.so: (memory/data?) [0x45AC] in (optimized out: previous android_memset32) [0x4590]
  libcutils.so: (memory/data?) [0x4650] in (optimized out: previous android_memset32) [0x4590]
  libcutils.so: (memory/data?) [0x46F9] in (optimized out: previous android_memset32) [0x4590]
  libcutils.so: (memory/data?) [0x474A] in (optimized out: previous android_memset32) [0x4590]
  libcutils.so: (memory/data?) [0x4807] in (optimized out: previous android_memset32) [0x4590]

Bug: 11353056
Change-Id: Id4a76b310be7fe858a8a60d0d260b09913b66be9
2013-10-23 13:45:01 -07:00
Nick Kralevich
3d4470c14a change wording on text relocation message.
The current message is too alarmist.

Change-Id: I53e8eadca239f867b4e6b9c193eba96e267950c3
2013-10-22 12:06:36 -07:00
Elliott Hughes
2258347f3b Build the linker with the same -std flags as the rest of bionic.
Change-Id: I5bdb28ecfdf78a90f6b072077a1c5ffd63f5d2ae
2013-10-17 13:06:20 -07:00
Elliott Hughes
41b87c6512 Merge "x86_64: Add R_X86_64_64 relocation handling" 2013-10-17 19:51:11 +00:00
Elliott Hughes
c7e9b23317 Fix sigaction(3) for 64-bit.
Also clean up <signal.h> and revert the hacks that were necessary
for 64-bit in linker/debugger.cpp until now.

Change-Id: I3b0554ca8a49ee1c97cda086ce2c1954ebc11892
2013-10-17 11:36:55 -07:00
Pavel Chupin
c075c18537 x86_64: Add R_X86_64_64 relocation handling
Change-Id: I86ffc56fa6a9053bed44e92a579530c2beb8eb2c
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-16 19:13:58 +04:00
Pavel Chupin
1a57f9f75c x86_64: Rename 64-bit linker to linker64
That's for having both on the same system.

Change-Id: Ic2bc2c015e6486e8b6a7576f7b28d2d027534368
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-09 16:50:30 -07:00
Elliott Hughes
eb847bc866 Fix x86_64 build, clean up intermediate libraries.
The x86_64 build was failing because clone.S had a call to __thread_entry which
was being added to a different intermediate .a on the way to making libc.so,
and the linker couldn't guarantee statically that such a relocation would be
possible.

  ld: error: out/target/product/generic_x86_64/obj/STATIC_LIBRARIES/libc_common_intermediates/libc_common.a(clone.o): requires dynamic R_X86_64_PC32 reloc against '__thread_entry' which may overflow at runtime; recompile with -fPIC

This patch addresses that by ensuring that the caller and callee end up in the
same intermediate .a. While I'm here, I've tried to clean up some of the mess
that led to this situation too. In particular, this removes libc/private/ from
the default include path (except for the DNS code), and splits out the DNS
code into its own library (since it's a weird special case of upstream NetBSD
code that's diverged so heavily it's unlikely ever to get back in sync).

There's more cleanup of the DNS situation possible, but this is definitely a
step in the right direction, and it's more than enough to get x86_64 building
cleanly.

Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
2013-10-09 16:00:17 -07:00
Elliott Hughes
2a0b873065 Fix __errno for LP64 and clean up __get_tls.
If __get_tls has the right type, a lot of confusing casting can disappear.

It was probably a mistake that __get_tls was exposed as a function for mips
and x86 (but not arm), so let's (a) ensure that the __get_tls function
always matches the macro, (b) that we have the function for arm too, and
(c) that we don't have the function for any 64-bit architecture.

Change-Id: Ie9cb989b66e2006524ad7733eb6e1a65055463be
2013-10-09 13:39:13 -07:00
Elliott Hughes
011bc0ba45 Use /system/lib64 and /vendor/lib64 for 64-bit libraries.
Change-Id: I4886aeb3070bf97b4cfe8053388ecb1bda288017
2013-10-08 14:27:10 -07:00
Elliott Hughes
0f395b7ba0 Make logging fall back to /dev/stderr if we're on the host.
Otherwise you get no logging, which sucks.

Change-Id: Iea1e8f996461afbb217a55711b7967005c39cfcb
2013-10-08 13:19:00 -07:00
Elliott Hughes
d7398f146d Use linker64 for the 64-bit linker.
Change-Id: I13fc7f93274f99e4cf99b077afdf5293e7233f39
2013-10-08 10:05:05 -07:00
Elliott Hughes
afac15d686 Use C99 structure initializer designator style.
clang warns about using the GCC style of designator.

Change-Id: I86ec79f06c8774618082859f48d7d1f576520e32
2013-10-08 10:01:09 -07:00
Elliott Hughes
c00f2cb587 x86_64 linker.
Based on I8dc3e2cb596f75dc58ae82e4dc58f8c177dd3323 by
Pavel Chupin <pavel.v.chupin@intel.com>.

Change-Id: Icd582d277cbe273477b450f2848343d72c86ec9f
2013-10-08 09:57:01 -07:00
Stephen Hines
99f0e1a329 Fix Clang warning since KernelArgumentBlock is actually a class.
Change-Id: Id72868d80feffbbc5f7d1e43beaed5d4e4d95f52
2013-10-08 00:08:13 -07:00
Elliott Hughes
c620059479 Remove 32-bit assumptions from the ELF code.
Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
2013-09-30 18:43:46 -07:00
Christopher Ferris
24053a461e Add the dl_iterate_phdr function to libdl for arm.
Bug: 8410085

Merge from internal master.

(cherry-picked from cb491bc66d)

Change-Id: I94ed51bc5d4c626df7552c0e85c31ccee2d6568f
2013-09-06 09:53:54 -07:00
Brian Carlstrom
87c358524e Make mips_relocate_got tolerate a missing got
Bug: 10094803

(cherry picked from commit 7ee26878065abb494600595349ce58b2b2db3709)

Change-Id: Ib15bccecaee421dc463d46a3956b054051708759
2013-08-21 10:20:13 -07:00
Brian Carlstrom
0e79b91962 Add more information to error due to truncated Elf32_Ehdr
Change-Id: I24f30bd0c1120bcf85d77f5c4e69f0fefe9a2478
2013-08-14 15:47:46 -07:00