flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > FASMARM: problem with referencing external symbols

Author
Thread Post new topic Reply to topic
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 24 Jun 2020, 13:45
When assembling the following code with FASM, the generated ELF object file contains one relocation as expected:
Code:
format ELF
section 'test' executable

extrn test_sym

mov eax, [test_sym]    

readelf --relocs extrn_ref.o:
Code:
Relocation section '.reltest' at offset 0x3c contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000001  00000201 R_386_32          00000000   test_sym    

However, similar code assembled with FASMARM generates no relocations and the reference to test_sym seems to be lost:
Code:
format ELF
section 'test' executable

extrn test_sym

ldr r0, [test_sym]    

readelf wrote:
There are no relocations in this file.


Am I doing something wrong?
Post 24 Jun 2020, 13:45
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 24 Jun 2020, 15:13
fasmarm has never officially supported ELF or relocations.

The ARM relocations are vastly different from the simpler x86. Sometimes the linker has to rewrite the code to support the external symbol.
Post 24 Jun 2020, 15:13
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 24 Jun 2020, 16:41
The docs say 'The "format" directive will produce ARM code in all the same formats as the X86 version'. That looks like ELF is supported, even ELF with DWARF is mentioned. What formats are actually officially supported?
Post 24 Jun 2020, 16:41
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 799
Location: Russian Federation, Sochi
ProMiNick 24 Jun 2020, 20:05
atleast question should be asked this way
Code:
format ELF
section 'test' executable

extrn test_sym

ldr r0, [liter_@1]
ldr r0, [r0]  
liter_@1 dw test_sym    

argument of ARM instructions COULDN`T BE RELOCATED to 32bit dword, so they should be somewhere near PC as "dw value".
In ARM test_sym should have same relocation type index as R_386_32 has.
If in fasmarm relocations would copy fasm behavior, ARM ELF should be workable.

In ARM only 2 instructions thou should avoid are movw movt, relocation of them is painfull process completely different from x86 relocations.
But if relocs cutted off from ELF it is bad.
Post 24 Jun 2020, 20:05
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 25 Jun 2020, 09:02
MazeGen wrote:
The docs say 'The "format" directive will produce ARM code in all the same formats as the X86 version'. That looks like ELF is supported, even ELF with DWARF is mentioned. What formats are actually officially supported?
fasmarm can make an ELF in x86 format with ARM code inside (although that is probably not used by anyone). But the ELF format for ARM is mostly similar, so it will work in some cases by just changing the machine type in the header.

Relocations is on my roadmap. I had started some work on them before my secondment, but they not yet available.
Post 25 Jun 2020, 09:02
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 799
Location: Russian Federation, Sochi
ProMiNick 25 Jun 2020, 21:56
revolution, when we could expect continue of thour brilliant work with fasmarm.
ARM architecture not died by time, but greatfully evolving.
So interest to thour fasmarm would only grow in the future.
(Apple start to cancel from x86 to ARM - maybe it would be more global tendention.)
Post 25 Jun 2020, 21:56
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 26 Jun 2020, 11:00
ProMiNick wrote:
revolution, when we could expect continue of thour brilliant work with fasmarm.
I don't know.

If you can help me to find a route, any route, from anywhere to anywhere else on this map then it might be a start. Travelling now is almost impossible without a direct flight and 14-day quarantine.


Description: Blue means no international arrival or transit AFAICT.
Filesize: 49.02 KB
Viewed: 8648 Time(s)

iata-border-closures.png


Post 26 Jun 2020, 11:00
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 26 Jun 2020, 20:45
<OffTop>Belarus has recently added somewhat between 10 and 20 countries where you can come from without having 14-day quarantine. Might not help you though, unless you’re willing to change your citizenship.</OffTop>
Post 26 Jun 2020, 20:45
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.