public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* gas section alignment less than 4 bytes
@ 2023-07-03 20:56 Vincent Rivière
  2023-07-03 21:03 ` Andreas Schwab
  2023-07-04 11:08 ` Nick Clifton
  0 siblings, 2 replies; 3+ messages in thread
From: Vincent Rivière @ 2023-07-03 20:56 UTC (permalink / raw)
  To: binutils

Hi,

I wonder if there is a way for gas to generate an object with section 
alignment less than 4.

$ echo nop | m68k-elf-as -o a.o

$ m68k-elf-objdump -h a.o

a.o:     file format elf32-m68k

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
   0 .text         00000002  00000000  00000000  00000034  2**2
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   1 .data         00000000  00000000  00000000  00000038  2**2
                   CONTENTS, ALLOC, LOAD, DATA
   2 .bss          00000000  00000000  00000000  00000038  2**2

I would like to get Algn = 2**1 for all sections.
Is it possible to achieve that? How?

Cheers,

-- 
Vincent Rivière

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gas section alignment less than 4 bytes
  2023-07-03 20:56 gas section alignment less than 4 bytes Vincent Rivière
@ 2023-07-03 21:03 ` Andreas Schwab
  2023-07-04 11:08 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2023-07-03 21:03 UTC (permalink / raw)
  To: Vincent Rivière; +Cc: binutils

On Jul 03 2023, Vincent Rivière wrote:

> I wonder if there is a way for gas to generate an object with section
> alignment less than 4.

It's hardcoded, see md_begin.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gas section alignment less than 4 bytes
  2023-07-03 20:56 gas section alignment less than 4 bytes Vincent Rivière
  2023-07-03 21:03 ` Andreas Schwab
@ 2023-07-04 11:08 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2023-07-04 11:08 UTC (permalink / raw)
  To: Vincent Rivière, binutils

Hi Vincent,

> I wonder if there is a way for gas to generate an object with section alignment less than 4.

If you do not mind the section having a name other than .text, then sure:

   $ cat fred.s
   .section foo, "ax"
   nop

   $ m68k-elf-as fred.s -o fred.o
   $ m68k-elf-objdump -h fred.o
   [...]
   3 foo           00000002  00000000  00000000  00000034  2**0
                   CONTENTS, ALLOC, LOAD, READONLY, CODE


> I would like to get Algn = 2**1 for all sections.
> Is it possible to achieve that? How?

If you want to change the alignment of all of the sections, then
you cannot do it using gas, but you can using objcopy:

   $ echo nop | m68k-elf-as -o a.o
   $ mk68k-elf-objcopy --set-section-alignment=\*=2 a.o b.o
   $ m68k-elf-objdump -h b.o
   [...]
   0 .text         00000002  00000000  00000000  00000034  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   1 .data         00000000  00000000  00000000  00000036  2**1
                   CONTENTS, ALLOC, LOAD, DATA
   2 .bss          00000000  00000000  00000000  00000036  2**1
                   ALLOC

Cheers
   Nick


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-04 11:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 20:56 gas section alignment less than 4 bytes Vincent Rivière
2023-07-03 21:03 ` Andreas Schwab
2023-07-04 11:08 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).