NetBSD-Bugs archive

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

Re: port-i386/47061: ld.elf_so does not understand R_386_TLS_TPOFF32



On Friday 12 October 2012 11:20:00 apb%cequrux.com@localhost wrote:
> >Number:         47061
> >Category:       port-i386
> >Synopsis:       ld.elf_so does not understand R_386_TLS_TPOFF32

The attached patch adds support and adds in addend (presumably always zero) 
for R_386_TLS_TPOFF.

It's untested.

Nick
Index: libexec/ld.elf_so/arch/i386/mdreloc.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/arch/i386/mdreloc.c,v
retrieving revision 1.34
diff -u -p -u -r1.34 mdreloc.c
--- libexec/ld.elf_so/arch/i386/mdreloc.c       25 Mar 2011 18:07:05 -0000      
1.34
+++ libexec/ld.elf_so/arch/i386/mdreloc.c       19 Oct 2012 10:11:18 -0000
@@ -121,6 +121,7 @@ _rtld_relocate_nonplt_objects(Obj_Entry 
                        break;
 
                case R_TYPE(TLS_TPOFF):
+               case R_TYPE(TLS_TPOFF32):
                        def = _rtld_find_symdef(symnum, obj, &defobj, false);
                        if (def == NULL)
                                return -1;
@@ -129,9 +130,13 @@ _rtld_relocate_nonplt_objects(Obj_Entry 
                            _rtld_tls_offset_allocate(obj))
                                return -1;
 
-                       *where = (Elf_Addr)(def->st_value - defobj->tlsoffset);
+                       if (ELF_R_TYPE(rel->r_info) == R_TYPE(TLS_TPOFF))
+                               *where += (Elf_Addr)(def->st_value - 
defobj->tlsoffset);
+                       else
+                               *where += (Elf_Addr)(defobj->tlsoffset - 
def->st_value);
 
-                       rdbg(("TLS_TPOFF %s in %s --> %p",
+                       rdbg(("TLS_TPOFF%s %s in %s --> %p",
+                           ELF_R_TYPE(rel->r_info) == R_TYPE(TLS_TPOFF) ? "" : 
"32",
                            obj->strtab + obj->symtab[symnum].st_name,
                            obj->path, (void *)*where));
                        break;


Home | Main Index | Thread Index | Old Index