flat assembler
Message board for the users of flat assembler.

Index > Windows > Using GCC (ld.exe) linking issue

Author
Thread Post new topic Reply to topic
magic



Joined: 17 Jan 2006
Posts: 3
magic 10 Dec 2012, 18:41
Hi can someone help me on this matter. I create a win32 asm program that will call another function in another win32 asm file. Both will be in ELF format. I link them using GCC(ld.exe) tool but fail. This is my code

For main file name main.asm:
Code:
format ELF

include 'win32a.inc'

  extrn '__imp__MessageBoxA@16' as MessageBox:dword
     extrn '__imp__ExitProcess@4' as ExitProcess:dword
     extrn '_myInfoBox@4' as myInfoBox:dword

section '.data' writeable

        title   db      'Title',0
 info    db      'Testing String',0

section '.code' executable writeable

      public _WinStart
    _WinStart:
                      invoke  MessageBox,     0,info,title,0  
                    push info
                   call myInfoBox
                      invoke  ExitProcess,    0
    


The error is;
Undefined refrence to '__imp__ExitProcess@4'
For me its should not error because I already refrence it in main file.


Last edited by magic on 11 Dec 2012, 18:06; edited 1 time in total
Post 10 Dec 2012, 18:41
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 10 Dec 2012, 22:29
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 22:12; edited 1 time in total
Post 10 Dec 2012, 22:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20413
Location: In your JS exploiting you and your system
revolution 11 Dec 2012, 00:38
For a linkable Windows output (an object file) you would use either "format coff" or "format ms coff".
Post 11 Dec 2012, 00:38
View user's profile Send private message Visit poster's website Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 11 Dec 2012, 00:52
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 22:12; edited 1 time in total
Post 11 Dec 2012, 00:52
View user's profile Send private message Reply with quote
khatch



Joined: 24 Oct 2011
Posts: 74
khatch 22 Dec 2012, 14:39
Hello.
The answer is:
Code:
format ELF

;include 'win32a.inc'

        extrn '__imp__MessageBoxA@16' as MessageBox:dword
     extrn '__imp__ExitProcess@4' as ExitProcess:dword
;        extrn '_myInfoBox@4' as myInfoBox:dword
extrn ___main  ;                  ; for mingw32

section '.data' writeable

 title   db      'Title',0
 info    db      'Testing String',0

section '.code' executable writeable

;        public _WinStart
;        _WinStart:
include 'win32a.inc'
public _main
_main:
                      call ___main    ; for mingw32
                       invoke  MessageBox,     0,info,title,0
;                        push info
;                        call myInfoBox
                     invoke  ExitProcess,    0 
    

And then:
gcc main.o -o final_GUI.exe -Wl,--subsystem=windows

gcc main.o -o final_CONSOLE.exe -Wl,--subsystem=console

_________________
Jesus Christ is our Savior
Post 22 Dec 2012, 14:39
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.