]> granicus.if.org Git - yasm/commitdiff
Fix #202 (incorrect GOT offset generated in NASM mode).
authorPeter Johnson <peter@tortall.net>
Sat, 15 May 2010 07:45:48 +0000 (07:45 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 15 May 2010 07:45:48 +0000 (07:45 -0000)
Don't generate an additional offset for _GLOBAL_OFFSET_TABLE_ if a WRT was
specified (the NASM usage).  In GAS, _GLOBAL_OFFSET_TABLE_ doesn't have a WRT
but instead has special handling.

This isn't quite *exactly* the right fix; a better fix would be to recognize
the _GLOBAL_OFFSET_TABLE_ case in the GAS parser and adjust the value
appropriately there.  However, this fix seems to do the right thing in the
meantime for both GAS and NASM cases.

svn path=/trunk/yasm/; revision=2321

modules/objfmts/elf/elf-x86-x86.c
modules/objfmts/elf/tests/elfso.hex

index d2fa6d1e2fc551e49909873bd6d1e353600ec9d4..3c5157fe81d9ae8fbdb696d37c4ed8b61f603142 100644 (file)
@@ -140,18 +140,7 @@ elf_x86_x86_handle_reloc_addend(yasm_intnum *intn,
                                 elf_reloc_entry *reloc,
                                 unsigned long offset)
 {
-    int is_GOT = reloc->is_GOT_sym;
-
-    if (reloc->wrt) {
-        const elf_machine_ssym *ssym = (elf_machine_ssym *)
-            yasm_symrec_get_data(reloc->wrt, &elf_ssym_symrec_data);
-        if (!ssym || reloc->valsize != ssym->size)
-            yasm_internal_error(N_("Unsupported WRT"));
-        if (ssym->reloc == R_386_GOTPC)
-            is_GOT = 1;
-    }
-
-    if (is_GOT && reloc->valsize == 32 && offset != 0)
+    if (!reloc->wrt && reloc->is_GOT_sym && reloc->valsize == 32 && offset != 0)
     {
         yasm_intnum *off_intn = yasm_intnum_create_uint(offset);
         yasm_intnum_calc(intn, YASM_EXPR_ADD, off_intn);
index 94a50cbd02718fe9cc54d56a0f121301e808ed76..206cce9c6d446e39328707da0b977f9978eeb0d6 100644 (file)
@@ -88,7 +88,7 @@ e8
 5b 
 81 
 c3 
-05 
+03 
 00 
 00 
 00