NO

Author Topic: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO  (Read 7165 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: 179
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.

Git

  • Guest
Re: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO
« Reply #5 on: April 03, 2020, 03:21:25 PM »
I am getting the same error from 9.00.9 :

POLINK: error: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO, for symbol 'biggy'.

I have several initialed variables in a DATA segment, and some code in a CODE segment. POLINK kicks out that error for each variable declared. Dumpbin shows that all those variables are ADDR32 relocs.. I don't want or need 32bit anything in this program. I have a simple 64bit C program calling a simple 64bit asm function.

Could anybody please explain how to fix this?. Id there a particular project setting or assembler directive or keyword missing?. Any help on this will be greatly appreciated, it's driving me nuts, as is being stuck indoors during this COVID19 pandemic.

Here's the rub - it was all ok, compiled, assembled, linked and just about ran. I changed that good ole "something, I forget..." and it started throwing these ADDR32 link errors. It's telling me to set /LARGEADDRESSAWARE:NO but I really don't want to do that.

Git


Code: [Select]
.MODEL FLAT, FASTCALL

EXTERN cos: PROC
EXTERN modf: PROC

.DATA
ALIGN 16

biggy OWORD 12345678123456781234567812345678
qA QWORD 84BD228634A74B22h
dubB  REAL8 100.0

.CODE
ALIGN 16

gen_nums proc public
local y:qword
push  blah
push  more
mov   etc
movsd xmm1, dubB
etc
...
...

gen_nums endp

ENDS



Later : In line with Pelles wishes in his message at the top of the bug reports forum, I'm attaching a minimal project that exhibits the problem. The code doesn't do anything else sensible.

Git
« Last Edit: April 03, 2020, 03:46:17 PM by Git »

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO
« Reply #6 on: April 05, 2020, 05:40:32 PM »
This has already been answered. In this thread. Use rip-relative addressing on x64!!
/Pelle

Git

  • Guest
Re: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO
« Reply #7 on: April 05, 2020, 05:54:06 PM »
Could you give a brief example please? I have no idea what RIP addressing is, I have never crossed paths with it. It would be very useful if you or somebody could show what needs to change in that brief example I uploaded to make it RIP relative. Thank you.

Git
« Last Edit: April 05, 2020, 06:01:20 PM by Git »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Relocation type ADDR32 is invalid without /LARGEADDRESSAWARE:NO
« Reply #8 on: April 06, 2020, 08:31:27 AM »
Code: [Select]
.MODEL FLAT, FASTCALL

.DATA
ALIGN 16
dubB  REAL8 100.0

.CODE
ALIGN 16

mainCRTStartup proc
; movsd xmm1, dubB
movsd xmm1, [RIP+dubB]
ret
mainCRTStartup endp

END
May the source be with you