This is the mail archive of the
mailing list for the binutils project.
linking problem - mips32 Android
- From: Andrzej Warzynski <andrzej at codeplay dot com>
- To: binutils at sourceware dot org
- Date: Mon, 24 Aug 2015 16:52:29 +0100
- Subject: linking problem - mips32 Android
- Authentication-results: sourceware.org; auth=none
- Authentication-results: mail.codeplay.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=codeplay.com
- References: <55D6E85D dot 8030105 at codeplay dot com>
We've recently came across a weird behavior with ld, and I wanted to
check whether this is a known issue and what's the best way to solve it.
We're using ld to link position independent binaries (passing the -pie
flag) for mips32 devices running Android. The problem is that ld marks
such binaries as shared when parsing arguments. This is implemented in
the parse_args() function in the lexsup.c file:
link_info.shared = TRUE;
link_info.pie = TRUE;
However, having been compiled with -pie does not necessarily imply that
it is a shared object, it could be an executable. Indeed, Android
requires all binaries to be position independent (i.e. linked with the
-pie flag), both shared objects and executables.
The above situation is particularly problematic for us, because it
prevents the _bfd_mips_elf_size_dynamic_sections() function in the
elfxx-mips.c file from adding the DT_MIPS_RLD_MAP structure to the
.dynamic section. This is due to the following check on line 9786 in
if (!info->shared && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP,
This check means that DT_MIPS_RLD_MAP will not be added if the file
that's being processed is flagged as shared. The DT_MIPS_RLD_MAP
structure is used by debuggers to track loading and unloading of shared
objects. The above behavior (i.e. flagging all position independent
binaries as shared objects) renders debugging executables for mips32
Is it necessary to flag all position independent executables as shared?
There's a bunch of easy workarounds, but we're not really sure what
would be the optimal solution.