I am attempting to compile Agner Fog's asmlib files with jwasm for usage in 64bit Linux.
I am having problems with the 64bit ELF format regarding the relocation section names.
When I compile my gnu asm and run readelf -a on the files, I see that I have Relocation section '.rela.text' and '.rela.data', but when using jwasm, I only get '.rel.text' and '.rel.data'.
When I attempt to link the object code to my other objects, I have relocation problems on the linkage. I feel like there need to be some patches to the elf.c code?
Can anybody help me with this, or tell me how I might go about fixing it without becoming an expert on the ELF format?
I also run into a bunch of R_X86_64_PC32 relocation errors stating that I need to recompile the code with -fPIC for some of the assembly files. I haven't figured out how to get around this one either. Typically, I code in straight GNU ASM and use %RIP relative offsets for functions/labels/vars, but this seems to be a little bit different in the MASM world. - any help would be appreciated.
Link
JROC
JROC
2010-10-30
I also wanted to mention that I think this assembler is pretty awesome.
AND.. I found that when compiled as a 64bit executable, it is broken.
On RedHat 5.5 x86_64, I had to modify the gcc unix make file to have -m32 for all the cflags to build jwasm such that it would produce usable results. I'm not quite sure what in the sources didn't work under the 64bit compilation. I didn't take the time to figure it out since I'm mainly focused on getting Agner Fog's library compiled under 64bit and working correctly.
Link
japheth
japheth
2010-10-31
When I attempt to link the object code to my other objects, I have relocation problems on the linkage. I feel like there need to be some patches to the elf.c code?
I'll need at least a test case to see those "relocation problems" myself
Link
JROC
JROC
2010-11-01
Ok, I've sent a tarball to what I am guessing is your source forge email address. Please let me if you receive it.
It's a test case of attempting to build a shared object file under x86_64 linux.
Thanks,
Eric
Link
japheth
japheth
2010-11-02
I received it.
Link
JROC
JROC
2010-11-02
great… - thanks.
Link
japheth
japheth
2010-11-03
I took a look.
There are 64-bit offsets in the assembly source, which make JWasm generate R_X86_64_64 relocations in .rel.data. This isn't compatible with PIC.
Generally, JWasm still lacks ELF-specific operators ( something like IMAGEREL/SECTIONREL for coff ) to support relocations which are to go into .rel.dyn and/or rel.plt. I guess, without such operators PIC code will be difficult to write with JWasm.
The small bug concerning forward references (memcpy64.asm.fails_with_jwasm) has been fixed.
Link
JROC
JROC
2010-11-03
thanks for taking a look and getting that other bug fixed.
am I correct to assume that 64bit PIC support will be well off into the future at this point?
For what it's worth, the nasm source code has what appears to be a fairly robust elf64.c file that might support the 64 bit PIC operations. That might be a good source for comparison.
Link
japheth
japheth
2010-11-03
am I correct to assume that 64bit PIC support will be well off into the future at this point?
this topic made me think about the priorities. Support for shared object should clearly have a higher priority than support for the dwarf debugging format.
That doesn't mean it will be implemented in 2 weeks. IMO the big problem with this issue is that currently there exists no convincing implementation of shared object support in current intel-based assemblers (NASM/YASM/FASM). It's all very low-level and error-prone - who has ever used this stuff?
Link
JROC
JROC
2010-11-03
Obviously, the intricacies of the object file formats are a bit over my head at the moment, but after this latest attempt to compile and link Agner's fast memcopy/memset routines they are starting to gain my attention.
The sad thing is, I never even heard of dwarf before until I started seeing it my compiled assembly dumps. I have been stripping all of the dwarf related stuff out of my assembly code, so as far as I know (naively speaking) I have no need for dwarf info at the moment.
I'll keep watching the forum to see how the progress is going. In the meantime, I'm hand converting the memcpy64.asm over to GAS format. I hope I can figure it out. I just started doing assembly hard core a month ago.
Link
JROC
JROC
2010-11-04
I ported the memcpy64.asm over to GAS assembly as PIC code (%rip relative) and it seems to be working fine.
If you are interested in having a copy of it to use in debugging of these problems, let me know and I will email it to you.
Link
drizz
drizz
2010-11-05
+1 for this feature and for lin64-abi-"invoke"
the way i understand it, it is impossible to call external functions with -elf64?
as a workaround you can compile to "-win64" and convert with objconv (Agner Fog)
jwasm -q -c -win64 -zcw -Fo $object $file
wine objconv.exe -felf64 -wd2005 -nu $object $object
// $object $file are code::blocks macros