Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ld.elf_so Check in workaround for BFD ABI change on ...



details:   https://anonhg.NetBSD.org/src/rev/9cd3ae67759c
branches:  trunk
changeset: 519245:9cd3ae67759c
user:      rafal <rafal%NetBSD.org@localhost>
date:      Thu Dec 13 21:41:58 2001 +0000

description:
Check in workaround for BFD ABI change on MIPS: the new MIPS BFD generates
relocs for local symbols as section-relative REL32 relocs with values based
at 0, whereas previously BFD generated those relocs with values based at the
start address of the section.

This code adjusts all STT_SECTION REL32 relocs which have values less than
the start of the section by adding in the base address of the section.  This
may limit section sizes to 2GB, but that shouldn't be a problem for now.

XXX: Needs to be followed-up with binutils list to get closure on which
interpretation is correct (the new ABI or the old one), I just haven't
yet had the time to chase that.

diffstat:

 libexec/ld.elf_so/reloc.c |  30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 5ba895a63b13 -r 9cd3ae67759c libexec/ld.elf_so/reloc.c
--- a/libexec/ld.elf_so/reloc.c Thu Dec 13 21:34:04 2001 +0000
+++ b/libexec/ld.elf_so/reloc.c Thu Dec 13 21:41:58 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: reloc.c,v 1.42 2001/09/10 06:09:41 mycroft Exp $        */
+/*     $NetBSD: reloc.c,v 1.43 2001/12/13 21:41:58 rafal Exp $  */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -337,9 +337,33 @@
                if (ELFDEFNNAME(ST_BIND)(def->st_info) == STB_LOCAL &&
                  (ELFDEFNNAME(ST_TYPE)(def->st_info) == STT_SECTION ||
                   ELFDEFNNAME(ST_TYPE)(def->st_info) == STT_NOTYPE)) {
+                       /*
+                        * XXX: ABI DIFFERENCE!
+                        * 
+                        * Old NetBSD binutils would generate shared libs
+                        * with section-relative relocations being already
+                        * adjusted for the start address of the section.
+                        * 
+                        * New binutils, OTOH, generate shared libs with
+                        * the same relocations being based at zero, so we
+                        * need to add in the start address of the section.  
+                        * 
+                        * We assume that all section-relative relocs with
+                        * contents less than the start of the section need 
+                        * to be adjusted; this should work with both old
+                        * and new shlibs.
+                        * 
+                        * --rkb, Oct 6, 2001
+                        */
+                       if (def->st_info == STT_SECTION && 
+                                   (*where < def->st_value))
+                           *where += (Elf_Addr) def->st_value;
+
                        *where += (Elf_Addr)obj->relocbase;
-                       rdbg(dodebug, ("REL32 in %s --> %p", obj->path,
-                           (void *)*where));
+
+                       rdbg(dodebug, ("REL32 %s in %s --> %p in %s",
+                           obj->strtab + def->st_name, obj->path,
+                           (void *)*where, obj->path));
                } else {
                        /* XXX maybe do something re: bootstrapping? */
                        def = _rtld_find_symdef(_rtld_objlist, rela->r_info,



Home | Main Index | Thread Index | Old Index