From 7adc41bfaba54a9d1fe82cfa59d7fc90da7defb4 Mon Sep 17 00:00:00 2001 From: Michael Urman Date: Sat, 2 Aug 2003 03:31:13 +0000 Subject: [PATCH] Actually use provided relocation type, instead of feeble-minded guessing. Add test case that centers on relocations; update test case that uses them. svn path=/trunk/yasm/; revision=1023 --- modules/objfmts/elf/elf.c | 5 +- modules/objfmts/elf/tests/Makefile.inc | 3 + modules/objfmts/elf/tests/elf-x86id.hex | 166 +++---- modules/objfmts/elf/tests/elfreloc.asm | 7 + modules/objfmts/elf/tests/elfreloc.errwarn | 0 modules/objfmts/elf/tests/elfreloc.hex | 496 +++++++++++++++++++++ 6 files changed, 590 insertions(+), 87 deletions(-) create mode 100644 modules/objfmts/elf/tests/elfreloc.asm create mode 100644 modules/objfmts/elf/tests/elfreloc.errwarn create mode 100644 modules/objfmts/elf/tests/elfreloc.hex diff --git a/modules/objfmts/elf/elf.c b/modules/objfmts/elf/elf.c index ebb06663..e1394f9c 100644 --- a/modules/objfmts/elf/elf.c +++ b/modules/objfmts/elf/elf.c @@ -604,10 +604,7 @@ elf_secthead_write_relocs_to_file(FILE *f, elf_secthead *shead) r_sym = STN_UNDEF; vis = yasm_symrec_get_visibility(reloc->sym); - r_type = R_386_32; - if (vis & YASM_SYM_EXTERN) { /* XXX: this can't be why. */ - r_type = R_386_PC32; - } + r_type = (unsigned char) reloc->rtype; bufp = buf; YASM_WRITE_32_L(bufp, reloc->addr); diff --git a/modules/objfmts/elf/tests/Makefile.inc b/modules/objfmts/elf/tests/Makefile.inc index 056f5247..29b55b9a 100644 --- a/modules/objfmts/elf/tests/Makefile.inc +++ b/modules/objfmts/elf/tests/Makefile.inc @@ -13,3 +13,6 @@ EXTRA_DIST += modules/objfmts/elf/tests/elftimes.errwarn EXTRA_DIST += modules/objfmts/elf/tests/elf-x86id.asm EXTRA_DIST += modules/objfmts/elf/tests/elf-x86id.hex EXTRA_DIST += modules/objfmts/elf/tests/elf-x86id.errwarn +EXTRA_DIST += modules/objfmts/elf/tests/elfreloc.asm +EXTRA_DIST += modules/objfmts/elf/tests/elfreloc.errwarn +EXTRA_DIST += modules/objfmts/elf/tests/elfreloc.hex diff --git a/modules/objfmts/elf/tests/elf-x86id.hex b/modules/objfmts/elf/tests/elf-x86id.hex index 96012d41..7cb37ec0 100644 --- a/modules/objfmts/elf/tests/elf-x86id.hex +++ b/modules/objfmts/elf/tests/elf-x86id.hex @@ -62958,7 +62958,7 @@ c3 00 00 00 -02 +01 0d 00 00 @@ -63038,7 +63038,7 @@ cd 01 00 00 -02 +01 12 00 00 @@ -63062,7 +63062,7 @@ fc 03 00 00 -02 +01 12 00 00 @@ -63070,7 +63070,7 @@ fc 03 00 00 -02 +01 12 00 00 @@ -63126,7 +63126,7 @@ fd 08 00 00 -02 +01 0d 00 00 @@ -63166,7 +63166,7 @@ fd 09 00 00 -02 +01 0d 00 00 @@ -63214,7 +63214,7 @@ b3 0a 00 00 -02 +01 0d 00 00 @@ -63246,7 +63246,7 @@ e8 0a 00 00 -02 +01 0d 00 00 @@ -63254,7 +63254,7 @@ e8 0b 00 00 -02 +01 12 00 00 @@ -63302,7 +63302,7 @@ c5 0d 00 00 -02 +01 12 00 00 @@ -63334,7 +63334,7 @@ f2 0d 00 00 -02 +01 0d 00 00 @@ -63398,7 +63398,7 @@ d8 0f 00 00 -02 +01 12 00 00 @@ -63438,7 +63438,7 @@ d8 0f 00 00 -02 +01 12 00 00 @@ -63470,7 +63470,7 @@ ef 10 00 00 -02 +01 12 00 00 @@ -63486,7 +63486,7 @@ ef 10 00 00 -02 +01 12 00 00 @@ -63518,7 +63518,7 @@ ef 10 00 00 -02 +01 20 00 00 @@ -63550,7 +63550,7 @@ d4 10 00 00 -02 +01 0d 00 00 @@ -63574,7 +63574,7 @@ d4 11 00 00 -02 +01 0d 00 00 @@ -64206,7 +64206,7 @@ db 2f 00 00 -02 +01 12 00 00 @@ -64382,7 +64382,7 @@ f5 34 00 00 -02 +01 12 00 00 @@ -64430,7 +64430,7 @@ ea 35 00 00 -02 +01 12 00 00 @@ -64598,7 +64598,7 @@ c3 3e 00 00 -02 +01 12 00 00 @@ -64630,7 +64630,7 @@ fa 3e 00 00 -02 +01 12 00 00 @@ -64654,7 +64654,7 @@ fa 3f 00 00 -02 +01 12 00 00 @@ -64670,7 +64670,7 @@ fa 3f 00 00 -02 +01 12 00 00 @@ -64958,7 +64958,7 @@ b0 49 00 00 -02 +01 12 00 00 @@ -64998,7 +64998,7 @@ e7 4a 00 00 -02 +01 12 00 00 @@ -65014,7 +65014,7 @@ e7 4a 00 00 -02 +01 12 00 00 @@ -65030,7 +65030,7 @@ e7 4a 00 00 -02 +01 12 00 00 @@ -65654,7 +65654,7 @@ f7 65 00 00 -02 +01 12 00 00 @@ -65662,7 +65662,7 @@ f7 65 00 00 -02 +01 12 00 00 @@ -65678,7 +65678,7 @@ d4 66 00 00 -02 +01 12 00 00 @@ -65742,7 +65742,7 @@ e9 69 00 00 -02 +01 12 00 00 @@ -65750,7 +65750,7 @@ f1 69 00 00 -02 +01 12 00 00 @@ -65918,7 +65918,7 @@ de 71 00 00 -02 +01 12 00 00 @@ -65942,7 +65942,7 @@ d5 71 00 00 -02 +01 12 00 00 @@ -66198,7 +66198,7 @@ d8 7c 00 00 -02 +01 12 00 00 @@ -66222,7 +66222,7 @@ a6 7c 00 00 -02 +01 12 00 00 @@ -66278,7 +66278,7 @@ fb 7e 00 00 -02 +01 12 00 00 @@ -66294,7 +66294,7 @@ fb 7e 00 00 -02 +01 12 00 00 @@ -66502,7 +66502,7 @@ f4 8b 00 00 -02 +01 12 00 00 @@ -66782,7 +66782,7 @@ fc 95 00 00 -02 +01 12 00 00 @@ -67094,7 +67094,7 @@ a0 a0 00 00 -02 +01 12 00 00 @@ -67110,7 +67110,7 @@ b5 a0 00 00 -02 +01 12 00 00 @@ -67142,7 +67142,7 @@ a4 a1 00 00 -02 +01 12 00 00 @@ -67166,7 +67166,7 @@ a3 a3 00 00 -02 +01 12 00 00 @@ -67174,7 +67174,7 @@ b3 a3 00 00 -02 +01 12 00 00 @@ -67246,7 +67246,7 @@ ab a5 00 00 -02 +01 12 00 00 @@ -67270,7 +67270,7 @@ a6 a7 00 00 -02 +01 12 00 00 @@ -67278,7 +67278,7 @@ a7 a7 00 00 -02 +01 12 00 00 @@ -67318,7 +67318,7 @@ cd a8 00 00 -02 +01 12 00 00 @@ -67358,7 +67358,7 @@ cf a9 00 00 -02 +01 12 00 00 @@ -67366,7 +67366,7 @@ f1 a9 00 00 -02 +01 12 00 00 @@ -67374,7 +67374,7 @@ a9 aa 00 00 -02 +01 12 00 00 @@ -67382,7 +67382,7 @@ aa aa 00 00 -02 +01 12 00 00 @@ -67390,7 +67390,7 @@ aa aa 00 00 -02 +01 12 00 00 @@ -67398,7 +67398,7 @@ aa aa 00 00 -02 +01 12 00 00 @@ -67406,7 +67406,7 @@ aa ab 00 00 -02 +01 12 00 00 @@ -67414,7 +67414,7 @@ ab ab 00 00 -02 +01 12 00 00 @@ -67422,7 +67422,7 @@ ab ab 00 00 -02 +01 12 00 00 @@ -67430,7 +67430,7 @@ ab ab 00 00 -02 +01 12 00 00 @@ -67502,7 +67502,7 @@ b0 b0 00 00 -02 +01 12 00 00 @@ -67606,7 +67606,7 @@ b3 b3 00 00 -02 +01 12 00 00 @@ -67630,7 +67630,7 @@ a2 b3 00 00 -02 +01 12 00 00 @@ -67662,7 +67662,7 @@ b4 b4 00 00 -02 +01 12 00 00 @@ -67678,7 +67678,7 @@ b4 b6 00 00 -02 +01 12 00 00 @@ -67782,7 +67782,7 @@ b9 b9 00 00 -02 +01 12 00 00 @@ -67798,7 +67798,7 @@ b9 b9 00 00 -02 +01 12 00 00 @@ -67814,7 +67814,7 @@ a1 b9 00 00 -02 +01 12 00 00 @@ -67830,7 +67830,7 @@ ca b9 00 00 -02 +01 12 00 00 @@ -67846,7 +67846,7 @@ f3 b9 00 00 -02 +01 12 00 00 @@ -67854,7 +67854,7 @@ b9 ba 00 00 -02 +01 12 00 00 @@ -67934,7 +67934,7 @@ bc bc 00 00 -02 +01 12 00 00 @@ -68742,7 +68742,7 @@ fd e0 00 00 -02 +01 12 00 00 @@ -68782,7 +68782,7 @@ e2 e3 00 00 -02 +01 12 00 00 @@ -68798,7 +68798,7 @@ b2 e3 00 00 -02 +01 12 00 00 @@ -68822,7 +68822,7 @@ e4 e4 00 00 -02 +01 12 00 00 @@ -68966,7 +68966,7 @@ b1 e8 00 00 -02 +01 12 00 00 @@ -69014,7 +69014,7 @@ ea ea 00 00 -02 +01 12 00 00 @@ -69062,7 +69062,7 @@ bb eb 00 00 -02 +01 12 00 00 @@ -69310,7 +69310,7 @@ f2 f3 00 00 -02 +01 12 00 00 @@ -69366,7 +69366,7 @@ fc f3 00 00 -02 +01 12 00 00 @@ -69382,7 +69382,7 @@ f4 f4 00 00 -02 +01 12 00 00 diff --git a/modules/objfmts/elf/tests/elfreloc.asm b/modules/objfmts/elf/tests/elfreloc.asm new file mode 100644 index 00000000..d12f4469 --- /dev/null +++ b/modules/objfmts/elf/tests/elfreloc.asm @@ -0,0 +1,7 @@ +EXTERN constant +EXTERN function + +main: + mov eax, constant + call function + ret diff --git a/modules/objfmts/elf/tests/elfreloc.errwarn b/modules/objfmts/elf/tests/elfreloc.errwarn new file mode 100644 index 00000000..e69de29b diff --git a/modules/objfmts/elf/tests/elfreloc.hex b/modules/objfmts/elf/tests/elfreloc.hex new file mode 100644 index 00000000..d3e742ff --- /dev/null +++ b/modules/objfmts/elf/tests/elfreloc.hex @@ -0,0 +1,496 @@ +7f +45 +4c +46 +01 +01 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +03 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +00 +00 +00 +34 +00 +00 +00 +00 +00 +28 +00 +06 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +b8 +00 +00 +00 +00 +e8 +fc +ff +ff +ff +c3 +00 +01 +00 +00 +00 +01 +04 +00 +00 +06 +00 +00 +00 +02 +05 +00 +00 +00 +2e +74 +65 +78 +74 +00 +2e +72 +65 +6c +2e +74 +65 +78 +74 +00 +2e +73 +74 +72 +74 +61 +62 +00 +2e +73 +79 +6d +74 +61 +62 +00 +2e +73 +68 +73 +74 +72 +74 +61 +62 +00 +00 +00 +2d +00 +63 +6f +6e +73 +74 +61 +6e +74 +00 +66 +75 +6e +63 +74 +69 +6f +6e +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +f1 +ff +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +04 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +0c +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +21 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +5c +00 +00 +00 +2b +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +11 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +88 +00 +00 +00 +15 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +19 +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +a0 +00 +00 +00 +60 +00 +00 +00 +02 +00 +00 +00 +04 +00 +00 +00 +04 +00 +00 +00 +10 +00 +00 +00 +01 +00 +00 +00 +01 +00 +00 +00 +06 +00 +00 +00 +00 +00 +00 +00 +40 +00 +00 +00 +0b +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +00 +00 +00 +00 +07 +00 +00 +00 +09 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +4c +00 +00 +00 +10 +00 +00 +00 +03 +00 +00 +00 +04 +00 +00 +00 +04 +00 +00 +00 +08 +00 +00 +00 -- 2.49.0