This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Aligment of data in .text and .data section (Intel/Linux)


Frank Klemm writes:
 > I need something like:
 > 
 > --------- nasm ---------------------------------------
 > 	segment .data align=1
 > 	
 > 	db	0x8B, 0x44, 0x24
 > 	db	4
 > 	db	0xF7, 0xD8
 > ------------------------------------------------------
 > 
 > The following is not equivalent
 > 
 > --------- gas -----------------------------------------
 > .data
 > 	.byte	0x8B, 0x44, 0x24
 > 	.byte	4
 > 	.byte	0xF7, 0xD8
 > --------------------------------------------------------
 > 
 > It aligns the data to a boundery of 4.
 > If I name the segemnt different, it works, but I have a lot of other
 > problems:
 > 
 > --------- gas -------------------------------------------
 >    
 > .section "noname"
 > 	.byte	0x8B, 0x44, 0x24
 > 	.byte	4
 > 	.byte	0xF7, 0xD8
 > ---------------------------------------------------------
 > 
 > How can I EXPLICITELY select an section alignment without patching the *.o
 > files? Automatics are fine, I only need a switch to turn them of.

You can't reduce a section's existing alignment (doesn't make sense)
and gas _predefines_ .text, .data with >1 alignments.
[If gas didn't predefine .data, you wouldn't be having a problem.]

 > A constructed sample follows. I don't want to post the whole project
 > and the explanation.

I think one can construct a reasonable argument that gas
shouldn't be specifying the alignment of anything.  One can even
reasonably argue gas shouldn't be predefining .text/.data/.bss.
Leave that to external entities (programmer, compiler, linker
script, etc.).

I doubt there's a likelihood of i386-linux gas changing though.
Maybe an option to not predefine .text/.data/.bss (and anything else)
might be acceptable to the powers that be.

You can either modify the assembler yourself
(yes, I recognize maintaining local mods is REALLY ICKY!),
or use different section names.

If you're doing this kind of assembler programming,
using a different section name is probably the way to go anyway.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]