Title: [2015] trunk/uClibc/ldso/ldso/ldso.c:
Upstream r20438 | carmelo | 2007-11-16 15:32:35 +0100 (Fri, 16 Nov 2007)
| 25 lines
- Revision
- 2015
- Author
- bernds
- Date
- 2007-11-23 09:11:13 -0600 (Fri, 23 Nov 2007)
Log Message
Upstream r20438 | carmelo | 2007-11-16 15:32:35 +0100 (Fri, 16 Nov 2007) | 25 lines
If uClibc's ld.so encounters text relocations in a shared library - one
containing an object built without -fpic/-fPIC - then:
* If __FORCE_SHAREABLE_TEXT_SEGMENTS__, then it gives an error "Can't
modify %s's text section. Use GCC option -fPIC for shared objects,
please.\n" and exits.
* Otherwise, it makes the library's pages writable and relocates it.
If it encounters text relocations in a position-independent executable -
one containing an object built without -fpie/-fPIE/-fpic/-fPIC - then:
* If __FORCE_SHAREABLE_TEXT_SEGMENTS__, it does nothing about making the
pages writable, leading to a crash.
* Otherwise, the loop to make the pages writable uses the same variable
ppnt as used in an outer loop, messing up that outer loop and also causing
a crash.
This patch fixes both cases, by giving an error if
__FORCE_SHAREABLE_TEXT_SEGMENTS__ and saving and restoring ppnt otherwise.
Tested in both cases on ARM EABI.
Joseph S. Myers
[EMAIL PROTECTED]
Diffstat
ldso.c | 7 +++++++
1 files changed, 7 insertions(+)
Modified Paths
Diff
Modified: trunk/uClibc/ldso/ldso/ldso.c (2014 => 2015)
--- trunk/uClibc/ldso/ldso/ldso.c 2007-11-23 14:06:03 UTC (rev 2014)
+++ trunk/uClibc/ldso/ldso/ldso.c 2007-11-23 15:11:13 UTC (rev 2015)
@@ -289,6 +289,7 @@
_dl_debug_early("calling mprotect on the application program\n");
/* Now cover the application program. */
if (app_tpnt->dynamic_info[DT_TEXTREL]) {
+ ElfW(Phdr) *ppnt_outer = ppnt;
ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_val;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
@@ -297,7 +298,13 @@
(unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
+ ppnt = ppnt_outer;
}
+#else
+ if (app_tpnt->dynamic_info[DT_TEXTREL]) {
+ _dl_dprintf(_dl_debug_file, "Can't modify application's text section; use the GCC option -fPIE for position-independent executables.\n");
+ _dl_exit(1);
+ }
#endif
#ifndef ALLOW_ZERO_PLTGOT
_______________________________________________
Toolchain-commits mailing list
Toolchain-commits@blackfin.uclinux.org
http://blackfin.uclinux.org/mailman/listinfo/toolchain-commits