public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* DT_TEXTREL/.dynamic issue with the binutils 2.15 linker on ARM and Linux
@ 2004-05-28 15:24 David Poole
  2004-05-28 15:33 ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: David Poole @ 2004-05-28 15:24 UTC (permalink / raw)
  To: binutils

(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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-11-01 15:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-28 15:24 DT_TEXTREL/.dynamic issue with the binutils 2.15 linker on ARM and Linux David Poole
2004-05-28 15:33 ` Daniel Jacobowitz
2004-05-28 15:54   ` David Poole
2004-05-28 22:58     ` David Poole
2004-05-29  6:21   ` Alan Modra
2004-06-01 16:59     ` David Poole
2004-10-29 20:13       ` Daniel Jacobowitz
2004-10-30 13:17         ` Richard Earnshaw
2004-11-01 15:14           ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).