NO

Author Topic: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO  (Read 3386 times)

MichaelW

  • Guest
Using Version 8.00.60 (Win64), under Windows 8.1, 64-bit, No service pack (Build 9600)

I have a C main and an asm module with the relevant parts:
Code: [Select]
.data
itoa64_digits db "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
.code
itoa64 proc value:QWORD, string:QWORD, _radix:QWORD
...
movzx   rdx, BYTE PTR itoa64_digits[rax]
...
itoa64 endp

My initial attempts to build the project returned the error message:

Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO, for symbol 'itoa64_digits'.

I tried the build with "Large address aware" check box on the project options linker tab checked and unchecked, and got the same error message either way. I could not find anything relevant in the documentation, so I tried pasting -largeaddressaware:no in the library and object files field of the project linker options tab, and was able to do the build with no errors. When I returned to the project linker options tab the -largeaddressaware:no was missing from the library and object files field, and the "Large address aware" check box was checked, but as long as I didn't change anything on the tab, I could continue to build the project with no errors. I didn't try every possibility, but even checking the Generate MAP file check box would cause the error to return.

moreson

  • Guest
Re: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO
« Reply #1 on: August 01, 2015, 02:44:28 pm »
Definitely seems like a bug if it keeps removing that flag.

But you should really think twice about wanting to use absolute 32 bit addresses in 64 bit programs, for the most part they will work, but for a dll it's a really bad idea because most of Windows is gonna assume 64-bit programs can be relocated above 4G addresses and would potentially truncate your addresses.
You should get used to RIP relative addressing in x64, makes your code trivially PIC and will just work wherever it gets relocated at.
Code: [Select]
lea r10, [rip+itoa64_digits]
movzx edx, byte ptr [r10+rax]

MichaelW

  • Guest
Re: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO
« Reply #2 on: August 03, 2015, 07:25:09 pm »
It was not my intention to use absolute 32-bit addresses. I'm using 64-bit registers in 64-bit code, and expected 64-bit addresses. Your example code does work, but it involves two instructions. I can address the data with this:
Code: [Select]
movzx   rdx, BYTE PTR itoa64_digits[rip]

But I cannot find any syntax that will allow me to include the RAX index, or even a displacement.

moreson

  • Guest
Re: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO
« Reply #3 on: August 05, 2015, 07:40:16 am »
With RIP relative addressing you cannot include any index or scale in the addressing mode, there's only the RIP+signed32offset encoding.
So indexing local arrays on 64 bit does indeed require more instructions compared to 32 bit (unless you use absolute 32 bit addresses and make sure all pointers are below 4GB).
You do make up for it when referencing global or shared variables or functions though where 32 bit PIC code is quite a few more instructions (and memory loads).

Offline bitcoin

  • Member
  • *
  • Posts: 83
Re: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO
« Reply #4 on: February 24, 2020, 01:25:54 am »
I have such error with code:

Asm
Code: [Select]
.data
extern PA : qword
.code
RunASM proc
jmp qword ptr [PA]
RunASM endp
end

Code: [Select]
FARPROC p[17];
...
PA = p[0];
RunASM();

I try to compile some project, but have this error.