This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
DT_TEXTREL/.dynamic issue with the binutils 2.15 linker on ARM and Linux
- From: David Poole <daveml at mbuf dot com>
- To: binutils at sources dot redhat dot com
- Date: Fri, 28 May 2004 08:52:58 -0600
- Subject: DT_TEXTREL/.dynamic issue with the binutils 2.15 linker on ARM and Linux
(I'm far from an expert, ARM, ELF, or otherwise, so if I'm using some
wrong terms, bear with me.)
I'm working with ARM Linux and uClibc. The uClibc shared library loader
segfaults. I've tracked the problem down to the loader attempting to
modify a R_ARM_PC24 call in uClibc/ldso/ldso/arm/resolve.S. The
location needing the modification is in a .rel.text section and the
page is read-only. The loader attempts to modify a branch instruction
to include the correct offset and the CPU rightly faults.
The linker code needing relocation is:
_dl_linux_resolve:
stmdb sp!, {r0, r1, r2, r3, sl, fp}
sub r1, ip, lr
sub r1, r1, #4
add r1, r1, r1
ldr r0, [lr, #-4]
mov r3,r0
bl _dl_linux_resolver
mov ip, r0
ldmia sp!, {r0, r1, r2, r3, sl, fp, lr}
mov pc,ip
.size _dl_linux_resolve, .-_dl_linux_resolve
The "bl _dl_linux_resolver" is causing the problem.
The loader will mprotect() the text pages to read/write if the .dynamic
section contains a DT_TEXTREL. I've hacked the loader to always
mprotect read/write the pages and the loader works. Independently of
the first hack, I've hacked the linker to always add a DT_TEXTREL and
the loader works.
The current problem I'm trying to solve is to understand why the
DT_TEXTREL isn't appearing in the executable and whether it should be
there. I'm poking around in bfd/elf32-arm.h -
elf32_arm_size_dynamic_sections().
Is there a better way to write this code that won't require fixup
later? Is DT_TEXTREL supposed to be in .dynamic in this case? In a
nutshel, is this a glitch with the way the loader is implemented or is
this a glitch with the linker?
Thanks.
--
David Poole <dpoole *at* mobl.com>
Mobility Electronics, Idaho http://www.mobl.com
960 Broadway Avenue, Suite 300
Boise, ID 83706