Revert [1251]. From further investigation, ML64's generation of REL32 in

these cases seems to be a bug.  If you get a linker error about ADDR32, it
means you aren't using RIP-relative instructions.  Note this means to access
an array you need to do:
  lea rax, [var wrt rip] ; generates RIP-relative insn and REL32 reloc
  mov rcx, [rax+rbx]     ; rbx is index
and not:
  mov rcx, [var+rbx]     ; generates ADDR32 reloc
At least when trying to build a DLL (the ADDR32 reloc fails the DLL link).
When building statically, ADDR32 should work okay and thus the latter form
can be used.

svn path=/trunk/yasm/; revision=1257
0.5.0rc2
Peter Johnson 19 years ago
parent fc6e94054e
commit a43f40ebf3
  1. 6
      libyasm/bytecode.c
  2. 6
      libyasm/bytecode.h
  3. 11
      modules/objfmts/coff/coff-objfmt.c
  4. 40
      modules/objfmts/win64/tests/win64-dataref.hex

@ -432,12 +432,6 @@ yasm_bc_create_data(yasm_datavalhead *datahead, unsigned int size,
return yasm_bc_create_common(&bc_data_callback, data, line); return yasm_bc_create_common(&bc_data_callback, data, line);
} }
int
yasm_bc_is_data(const yasm_bytecode *bc)
{
return (bc->callback == &bc_data_callback);
}
static void static void
bc_reserve_destroy(void *contents) bc_reserve_destroy(void *contents)
{ {

@ -141,12 +141,6 @@ void yasm_bc_set_multiple(yasm_bytecode *bc, /*@keep@*/ yasm_expr *e);
/*@only@*/ yasm_bytecode *yasm_bc_create_data /*@only@*/ yasm_bytecode *yasm_bc_create_data
(yasm_datavalhead *datahead, unsigned int size, unsigned long line); (yasm_datavalhead *datahead, unsigned int size, unsigned long line);
/** Find out if a bytecode is a data bytecode.
* \param bc bytecode
* \return Nonzero if bytecode is a data bytecode, otherwise 0.
*/
int yasm_bc_is_data(const yasm_bytecode *bc);
/** Create a bytecode reserving space. /** Create a bytecode reserving space.
* \param numitems number of reserve "items" (kept, do not free) * \param numitems number of reserve "items" (kept, do not free)
* \param itemsize reserved size (in bytes) for each item * \param itemsize reserved size (in bytes) for each item

@ -455,7 +455,6 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char *buf, size_t destsize,
* $$ in. * $$ in.
* For Win32 COFF, need to reference to next bytecode, so add '$' * For Win32 COFF, need to reference to next bytecode, so add '$'
* (really $+$.len) in. * (really $+$.len) in.
* For Win64 COFF, don't add anything in.
*/ */
if (objfmt_coff->win32) if (objfmt_coff->win32)
*ep = yasm_expr_create(YASM_EXPR_ADD, yasm_expr_expr(*ep), *ep = yasm_expr_create(YASM_EXPR_ADD, yasm_expr_expr(*ep),
@ -478,16 +477,8 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char *buf, size_t destsize,
if (valsize == 32) { if (valsize == 32) {
if (info->csd->flags2 & COFF_FLAG_NOBASE) if (info->csd->flags2 & COFF_FLAG_NOBASE)
reloc->type = COFF_RELOC_AMD64_ADDR32NB; reloc->type = COFF_RELOC_AMD64_ADDR32NB;
else if (!objfmt_coff->win64 || yasm_bc_is_data(bc)) else
reloc->type = COFF_RELOC_AMD64_ADDR32; reloc->type = COFF_RELOC_AMD64_ADDR32;
else {
/* I don't understand this, but ML64 generates REL32
* for all instructions, regardless of whether they
* are RIP relative. Obviously this is either handled
* by the linker or by the compiler at a higher level!
*/
reloc->type = COFF_RELOC_AMD64_REL32;
}
} else if (valsize == 64) } else if (valsize == 64)
reloc->type = COFF_RELOC_AMD64_ADDR64; reloc->type = COFF_RELOC_AMD64_ADDR64;
else { else {

@ -682,7 +682,7 @@ c4
00 00
00 00
00 00
04 02
00 00
07 07
00 00
@ -712,7 +712,7 @@ c4
00 00
00 00
00 00
04 02
00 00
1f 1f
00 00
@ -752,7 +752,7 @@ c4
00 00
00 00
00 00
04 02
00 00
42 42
00 00
@ -762,7 +762,7 @@ c4
00 00
00 00
00 00
04 02
00 00
48 48
00 00
@ -782,7 +782,7 @@ c4
00 00
00 00
00 00
04 02
00 00
60 60
00 00
@ -812,7 +812,7 @@ c4
00 00
00 00
00 00
04 02
00 00
83 83
00 00
@ -822,7 +822,7 @@ c4
00 00
00 00
00 00
04 02
00 00
89 89
00 00
@ -862,7 +862,7 @@ a1
00 00
00 00
00 00
04 02
00 00
a8 a8
00 00
@ -902,7 +902,7 @@ bf
00 00
00 00
00 00
04 02
00 00
c4 c4
00 00
@ -912,7 +912,7 @@ c4
00 00
00 00
00 00
04 02
00 00
ca ca
00 00
@ -952,7 +952,7 @@ e2
00 00
00 00
00 00
04 02
00 00
e9 e9
00 00
@ -992,7 +992,7 @@ f8
00 00
00 00
00 00
04 02
00 00
05 05
01 01
@ -1002,7 +1002,7 @@ f8
00 00
00 00
00 00
04 02
00 00
0b 0b
01 01
@ -1042,7 +1042,7 @@ f8
00 00
00 00
00 00
04 02
00 00
2a 2a
01 01
@ -1082,7 +1082,7 @@ f8
00 00
00 00
00 00
04 02
00 00
46 46
01 01
@ -1092,7 +1092,7 @@ f8
00 00
00 00
00 00
04 02
00 00
4c 4c
01 01
@ -1132,7 +1132,7 @@ f8
00 00
00 00
00 00
04 02
00 00
6b 6b
01 01
@ -1172,7 +1172,7 @@ f8
00 00
00 00
00 00
04 02
00 00
87 87
01 01
@ -1560,7 +1560,7 @@ b6
00 00
00 00
00 00
04 02
00 00
2d 2d
00 00
@ -1600,7 +1600,7 @@ b6
00 00
00 00
00 00
04 02
00 00
2e 2e
66 66

Loading…
Cancel
Save