flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > Delphi + FASMARM *.obj files

Author
Thread Post new topic Reply to topic
DevilDevil



Joined: 19 Jul 2014
Posts: 3
DevilDevil 19 Jul 2014, 13:19
Hello

Could you show please, how can I make a simple *.obj ARM file and link it's public function into my Delphi project (Android or iOS)

Thank you
Post 19 Jul 2014, 13:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20343
Location: In your JS exploiting you and your system
revolution 19 Jul 2014, 13:23
I've never tried this but perhaps something like this:
Code:
format elf
public MyFunction

MyFunction:
        add     r0,r1,r2
        mov     r3,12
        bx      lr    
Post 19 Jul 2014, 13:23
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 19 Jul 2014, 13:59
revolution
Wouldn't almost any linking require the relocations to be setup correctly? Linkable formats seem to be still either under construction or even untouched by porting. E.g., coff and ms coff even set IMAGE_FILE_MACHINE_I386 .

_________________
Faith is a superposition of knowledge and fallacy
Post 19 Jul 2014, 13:59
View user's profile Send private message Reply with quote
DevilDevil



Joined: 19 Jul 2014
Posts: 3
DevilDevil 19 Jul 2014, 13:59
revolution

You did the magic! Thank you! It works!!!
Code:
{$ifdef CPUARM}
  function MyFunction(const X, Y, Z: integer): integer; external 'test_ARM.obj' name 'MyFunction';
{$endif}    

So:
1) why dont you defined any section/segment and how to define the standard sections like .code, .data, .const ?
2) how to compile thumb-2 obj files? seems like it's the standard Delphi binaries mode
Post 19 Jul 2014, 13:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20343
Location: In your JS exploiting you and your system
revolution 19 Jul 2014, 14:16
For thumb-2 just set the mode:
Code:
format elf
thumb ;by default all instructions are available so thumb-2 instructions will now be active, see the 'processor' directive for details
;...    
l_inc: From what I have seen coff formats are not useful for ARM code.

The relocations could be a problem if the code uses global variables. This will affect the usage of extrn also so I don't know what will happen there.
Post 19 Jul 2014, 14:16
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: 20343
Location: In your JS exploiting you and your system
revolution 19 Jul 2014, 14:53
I think this will work:
Code:
format elf
public MyFunction

extrn TheirFunction:word

MyFunction:
        push    {lr}
        ldr     r0,[TheirFunction]
        blx     r0
        pop     {pc}    
Post 19 Jul 2014, 14:53
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 19 Jul 2014, 14:54
revolution
I've never used MS COFF for ARM, but I suppose Visual Studio uses it to compile for ARM. The specification does define some values specifically for ARM.

_________________
Faith is a superposition of knowledge and fallacy
Post 19 Jul 2014, 14:54
View user's profile Send private message Reply with quote
DevilDevil



Joined: 19 Jul 2014
Posts: 3
DevilDevil 19 Jul 2014, 15:40
revolution,
Quote:
format elf
thumb

it's too weird, but the Delphi still try to call 32bit mode functions
Hmmm
maybe it's a Delphi or Android SDK bug

so... how to define data section in FASMARM?
I will try to use a thumb-2 function by the pointer
Post 19 Jul 2014, 15:40
View user's profile Send private message 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.