summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2010-05-15 07:45:48 +0000
committerPeter Johnson <peter@tortall.net>2010-05-15 07:45:48 +0000
commitd5ae19570398116de4d7c31d1a72de771715c138 (patch)
treed429bdabc9e18cb0aa0404f306998a4b610c683b
parent4003fa1bc0c69cf7cc08119b7452e3b8c68829cb (diff)
downloadyasm-d5ae19570398116de4d7c31d1a72de771715c138.tar.gz
Fix #202 (incorrect GOT offset generated in NASM mode).
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
-rw-r--r--modules/objfmts/elf/elf-x86-x86.c13
-rw-r--r--modules/objfmts/elf/tests/elfso.hex2
2 files changed, 2 insertions, 13 deletions
diff --git a/modules/objfmts/elf/elf-x86-x86.c b/modules/objfmts/elf/elf-x86-x86.c
index d2fa6d1e..3c5157fe 100644
--- a/modules/objfmts/elf/elf-x86-x86.c
+++ b/modules/objfmts/elf/elf-x86-x86.c
@@ -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);
diff --git a/modules/objfmts/elf/tests/elfso.hex b/modules/objfmts/elf/tests/elfso.hex
index 94a50cbd..206cce9c 100644
--- a/modules/objfmts/elf/tests/elfso.hex
+++ b/modules/objfmts/elf/tests/elfso.hex
@@ -88,7 +88,7 @@ e8
5b
81
c3
-05
+03
00
00
00