OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 10:25 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: .align 3 not working gnu as spits out errors
PostPosted: Sat Aug 18, 2018 8:48 pm 
Offline
Member
Member

Joined: Sat Aug 18, 2018 8:44 pm
Posts: 127
linux 0.01's boot.s has a assembler directive stating .align that is causing assembler to spit out error message... I can try to replace 3 with 4... the error go away... but based on the gas manual, .align 3 is a valid statement... was compiling in a vm ubuntu 64 bit machine...


thanks for the help...


Top
 Profile  
 
 Post subject: Re: .align 3 not working gnu as spits out errors
PostPosted: Sat Aug 18, 2018 9:09 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
Are you trying to align to a multiple of 3 instad of a multiple of 8?


Top
 Profile  
 
 Post subject: Re: .align 3 not working gnu as spits out errors
PostPosted: Sat Aug 18, 2018 11:54 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
When using elf format, the default for gas nowadays, the argument to .align must be a power of 2. The behaviour is different when using a.out format (which that version of Linux would have used) where the argument specifies the power of 2.

So .align 3 (a.out) is equivalent to .align 8 (elf).


Top
 Profile  
 
 Post subject: Re: .align 3 not working gnu as spits out errors
PostPosted: Sun Aug 19, 2018 1:13 am 
Offline
Member
Member

Joined: Sat Aug 18, 2018 8:44 pm
Posts: 127
Is there a way to choose zmagic/amagic over elf? What switch/flag is there? there doesn't seem to have any at first glance... just curious...

also by the same token, is .align 4 in a.out equivalent to .align 16 in elf?


Top
 Profile  
 
 Post subject: Re: .align 3 not working gnu as spits out errors
PostPosted: Sun Aug 19, 2018 2:02 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
ITchimp wrote:
Is there a way to choose zmagic/amagic over elf? What switch/flag is there? there doesn't seem to have any at first glance... just curious...


Try something like this (you'll likely need the object file, aout.o, already in a.out format, not ELF):
Code:
ld -e __start --oformat=a.out-i386 --omagic aout.o -o aout.out
ld -e __start --oformat=a.out-i386 --nmagic aout.o -o aout.out
ld -e __start --oformat=a.out-i386 --qmagic aout.o -o aout.out


ITchimp wrote:
also by the same token, is .align 4 in a.out equivalent to .align 16 in elf?

I'd expect so.


Top
 Profile  
 
 Post subject: Re: .align 3 not working gnu as spits out errors
PostPosted: Sun Aug 19, 2018 7:31 am 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 642
Location: Ukraine, Bachmut
iansjack wrote:
When using elf format, the default for gas nowadays, the argument to .align must be a power of 2. The behaviour is different when using a.out format (which that version of Linux would have used) where the argument specifies the power of 2.

So .align 3 (a.out) is equivalent to .align 8 (elf).


but don't forget, as always with this mess, - this is valid only for x86.

for example on both arm, mips and ppc gccs emitting elf, .align 3 means "align on 2^3". which is sane imho.

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: .align 3 not working gnu as spits out errors
PostPosted: Sun Aug 19, 2018 7:54 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
For compatible behaviour across architectures use .balign.

Of course, Linux 0.01 only supported x86 processors.


Top
 Profile  
 
 Post subject: Re: .align 3 not working gnu as spits out errors
PostPosted: Sun Aug 19, 2018 8:06 am 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 642
Location: Ukraine, Bachmut
iansjack wrote:
For compatible behaviour across architectures use .balign.

Of course, Linux 0.01 only supported x86 processors.

I noted that just in case, for the OP, maybe he/she is going to develop not only on x86. :mrgreen:

I prefer the meaning where N in .align N means power of two. so .balign is BS. .p2align is better. of course if one wants to mess with gcc specific directives (which .balign an .p2align are).

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: .align 3 not working gnu as spits out errors
PostPosted: Sun Aug 19, 2018 8:09 am 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 642
Location: Ukraine, Bachmut
iansjack wrote:
For compatible behaviour across architectures use .balign.

Of course, Linux 0.01 only supported x86 processors.

I noted that just in case, for the OP, maybe he/she is going to develop not only on x86. :mrgreen:

I prefer the meaning where N in .align N means log2(alignment), not the alignment itself. so .balign is BS. .p2align is better. of course if one wants to mess with gcc specific directives (which .balign an .p2align are).

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 87 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group