From Newsgroup: alt.lang.asm
Johanne Fairchild <
jfairchild@tudado.org> writes:
Taking my first steps with
The Art of 64-bit Assembly Language, Volume 1
Randall Hyde, No Starch Press, 2022
ISBN 978-1-7185-0109-6
I am being a bit cocky in trying to use the tools: instead of learning
to use cl, I'm trying to use gcc, which I'm more used to.
For the record, I did manage to learn enough of CL to compile and the
link the program. It was instructive to clear up what the issue is
about as I'll show below. I'm still unable to compile and the link the
program using GCC, so I'm still interested in learning how to do that.
(If that makes sense. If you tell me that these a MASM object code
should never be linked by the GNU linker, I'm all ears.)
Here's what I did.
%ml64 /c /Zi /Cp sort.asm
Microsoft (R) Macro Assembler (x64) Version 14.29.30148.0
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: sort.asm
Object code produced by MASM.
%cl /O2 /Zi /utf-8 /EHa /Fesort.exe main.c sort.obj
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30148 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
main.c
Microsoft (R) Incremental Linker Version 14.29.30148.0
Copyright (C) Microsoft Corporation. All rights reserved.
/debug
/out:sort.exe
main.obj
sort.obj
sort.obj : error LNK2017: 'ADDR32' relocation to 'sortme' invalid without /LARGEADDRESSAWARE:NO
LINK : fatal error LNK1165: link failed because of fixup errors
So it seems I'm being bitten by the fact that my program is using an instruction that's a variant of the indirect-plus-offset addressing mode
that's not available when my program wants to access the entirety of
memory of a 64-bit machine. Since I'm not acessing much memory, there's
no need for this, so I can follow the suggestion of the linker.
C:\sys\emacs\usr\tmp>cl /O2 /Zi /utf-8 /EHa /Fesort.exe main.c sort.obj /link /LARGEADDRESSAWARE:NO
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30148 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
main.c
Microsoft (R) Incremental Linker Version 14.29.30148.0
Copyright (C) Microsoft Corporation. All rights reserved.
/debug
/out:sort.exe
/LARGEADDRESSAWARE:NO
main.obj
sort.obj
So that worked. So my question becomes---how can I tell the GNU linker
to assemble my program ignoring the fact that I cannot reach the whole
of the machine's memory? In other words, what is the GNU linker's
/largeaddressaware:no
option, assuming there is one? Thank you so much.
(*) The program
It's a bubble sort implementation.
%./sort.exe
Invoking asmproc...
sortme[0] = 0
sortme[1] = 1
sortme[2] = 2
sortme[3] = 3
sortme[4] = 4
sortme[5] = 5
sortme[6] = 6
sortme[7] = 7
sortme[8] = 8
sortme[9] = 10
sortme[10] = 11
sortme[11] = 12
sortme[12] = 13
sortme[13] = 14
sortme[14] = 15
sortme[15] = 16
Done.
--- Synchronet 3.21d-Linux NewsLink 1.2