From: Bernd Schmidt <bernds_...@t-online.de>

This is needed for Blackfin FLAT's to be processed properly, and apparently
some other people have seen similar behavior.

http://lists.uclibc.org/pipermail/uclibc/2009-April/042363.html
http://thread.gmane.org/gmane.linux.hardware.blackfin.toolchain.devel/1121

Signed-off-by: Bernd Schmidt <bernds_...@t-online.de>
Signed-off-by: Mike Frysinger <vap...@gentoo.org>
---
 Makefile.in  |    3 ++-
 configure    |   21 +++++++++++++++++++++
 configure.in |   13 +++++++++++++
 elf2flt.c    |    2 +-
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 861f62b..81e1afc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -25,7 +25,8 @@ DEFS = @DEFS@ \
        -DTARGET_ALIAS=\"$(TARGET)\" \
        -dno_got_che...@got_check@ \
        -duse_emit_relo...@emit_relocs@ \
-       -demit_ctor_dt...@emit_ctor_dtor@
+       -demit_ctor_dt...@emit_ctor_dtor@ \
+       -dalways_reloc_te...@always_reloc_text@
 EXEEXT = @EXEEXT@
 OBJEXT = @OBJEXT@
 
diff --git a/configure b/configure
index 8177dff..6884892 100755
--- a/configure
+++ b/configure
@@ -638,6 +638,7 @@ ac_includes_default="\
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
 SYMBOL_PREFIX
+always_reloc_text
 emit_ctor_dtor
 emit_relocs
 got_check
@@ -722,6 +723,7 @@ enable_ld_elf2flt_binary
 enable_got_check
 enable_emit_relocs
 enable_emit_ctor_dtor
+enable_always_reloc_text
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1361,6 +1363,9 @@ Optional Features:
  --disable-got-check - disable check for GOT (needed on H8)
  --disable-emit-relocs - don't use the --emit-relocs (-q) linker option
   --enable-emit-ctor-dtor manually create ctor/dtor list
+  --enable-always-reloc-text
+                          always process text relocs ignoring pic/got (needed
+                          on Blackfin)
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1940,6 +1945,21 @@ fi
 
 var_yn_to_10 emit_ctor_dtor
 
+# Check whether --enable-always-reloc-text was given.
+if test "${enable_always_reloc_text+set}" = set; then
+  enableval=$enable_always_reloc_text;  always_reloc_text=$enableval
+else
+
+       case $target in
+               bfin*) always_reloc_text=yes;;
+               *)     always_reloc_text=no;;
+       esac
+
+
+fi
+
+var_yn_to_10 always_reloc_text
+
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
   if test -f "$ac_dir/install-sh"; then
@@ -5128,6 +5148,7 @@ test "$GCC" = yes && CFLAGS="-Wall $CFLAGS"
 
 
 
+
 ac_config_files="$ac_config_files ld-elf2flt.sh:ld-elf2flt.in Makefile 
elf2flt.ld"
 
 cat >confcache <<\_ACEOF
diff --git a/configure.in b/configure.in
index 8c4ebdb..6003d8c 100644
--- a/configure.in
+++ b/configure.in
@@ -79,6 +79,18 @@ AC_ARG_ENABLE(emit-ctor-dtor,
 )
 var_yn_to_10 emit_ctor_dtor
 
+AC_ARG_ENABLE(always-reloc-text,
+       AS_HELP_STRING([--enable-always-reloc-text], [always process text 
relocs ignoring pic/got (needed on Blackfin)]),
+       [ always_reloc_text=$enableval ],
+       [
+       case $target in
+               bfin*) always_reloc_text=yes;;
+               *)     always_reloc_text=no;;
+       esac
+       ]
+)
+var_yn_to_10 always_reloc_text
+
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 
@@ -207,6 +219,7 @@ AC_SUBST(use_ld_elf2flt_binary)
 AC_SUBST(got_check)
 AC_SUBST(emit_relocs)
 AC_SUBST(emit_ctor_dtor)
+AC_SUBST(always_reloc_text)
 AC_SUBST(SYMBOL_PREFIX)
 
 AC_OUTPUT(ld-elf2flt.sh:ld-elf2flt.in Makefile elf2flt.ld)
diff --git a/elf2flt.c b/elf2flt.c
index 5e9c698..2fea9b5 100644
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -396,7 +396,7 @@ dump_symbols(symbols, number_of_symbols);
         *      Only relocate things in the data sections if we are PIC/GOT.
         *      otherwise do text as well
         */
-       if (!pic_with_got && (a->flags & SEC_CODE))
+       if ((!pic_with_got || ALWAYS_RELOC_TEXT) && (a->flags & SEC_CODE))
                sectionp = text + (a->vma - text_vma);
        else if (a->flags & SEC_DATA)
                sectionp = data + (a->vma - data_vma);
-- 
1.6.6

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to