News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

AMD64 GAS Documtentation ?

Started by DarkWolf, December 24, 2007, 12:54:37 AM

Previous topic - Next topic

DarkWolf

Well GAS can do 64bit got that figured out.
(-64 switch and specify the arch)
But will there be a hiccup with ld ?
The docs for the linker show that the only 64 bit arch it supports is PowerPC64.
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

James Ladd

QuoteGAS syntax annoys me pretty bad.
So use the .intel directive to make it just like masm

GUAN DE DIO

Is it possible to work with GAS using the masm systaxis?

Could you tell me where I can download all the necessary to start work with GAS?

Thanks,
GUAN

DarkWolf

Yeah, you can use the intel directive like James posted to get masm like syntax.

Right now I am trying to get the linker ld to link 32bit code on a 64bit machine.
I know that sounds kinda weird but some tools and libraries I have are still 32bit and though I can run those programs on AMD64 but I can't build anything. I can get as to compile the code but ld won't link (I specify a 32bit target but ld says it can't either find it or warns me that I am on a 64bit platform).
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

MichaelW

FWIW, I posted a set of (32-bit) invoke macros for GAS here, and I noticed at the Binutils link that a new version was released on December 12.
eschew obfuscation

DarkWolf

My particular problem is using as/ld to compile 32bit code on a AMD64 Xubuntu machine.

All the code and libraries I have are for 32bit, AMD64 has a compatiblity mode to execute 32 applications but I can't compile them.
So I can run 32bit applications but have no means to continue to develop them.
I can get as to compile 32bit code but I can't get ld to link them.

This works:
as --32 something.s something.o
None of these do:
ld --oformat elf32_i386 something.o
ld --oformat a.out-i386-linux something.o
ld --oformat i386linux something.o
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

Rockoon

Wouldn't you use the -m switch for ld?

32bit:  –m elf_i386
64-bit: –m elf_x86_64

I am basing this on info from AMD's 64-bit linux support page:

http://developer.amd.com/documentation/articles/pages/914200640.aspx
When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.

DarkWolf

#22
I am not familiar with emulation in linkers.
To me emulation means to 'pretend', like how emulators on your pc 'pretend' to be another machine.
I was trying to get real 32bit code.

I'll try the -m switch in ld and see what happens.

(That works, I can compile but when I try to run program bash reports that permission is denied. Assuming it means file permissions I have permission to read/write and execute)
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

MichaelW

If the current problem is converting object modules between formats, Agner Fog has a tool for that:

http://www.agner.org/optimize/#objconv

eschew obfuscation

DarkWolf

I am not converting any object code.

(All the following is done on an AMD 64 machine)
I assembled 32 bit code using "as --32"
I linked that object into executable using "ld -m elf_i386"
And then I tried to execute the app.
The error I get is that permission is denied.
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

DarkWolf

Arrg, this is getting kinda frustrating.

I can finally get as to compile 32 bit code and ld to link 32 bit on a 64 bit processor but the application won't execute.
bash keeps telling me that permission is denied, (but permissions are set right)
Are there other permissions ??

How are you suppose to compile 32 bit code when manufacturers are changing over to multi-core 64 bit machines ?
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

DarkWolf

Here is what I got so far. I have gotten farther from my original question at least but not all the way there yet.

I can build 32 bit code with as (using --32)
I can link 32 bit code with ld (using -m elf_i386 and -m i386linux)

But it will not execute. (I attached readelf output for -m elf_i386)
The error I get is permission denied, which is wierd because I have rwx permissions for that directory and file.

I am not working on anything in particular, I am just trying to build the examples from the Programming from the Ground Up book to figure out how to build 32bit code on amd64.

[attachment deleted by admin]
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

James Ladd

If you dont like GAS syntax, then use the Intel directive and - presto ! - you can do away with
all the %%ages :)

DarkWolf

I don't have a particular issue with syntax, unless as is producing something that ld doesn't like.

Compiling and linking "appear'' to work but no 32bit app I build will run on a 64bit machine.
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.