public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: "Vincent Rivière" <vincent.riviere@freesbee.fr>, binutils@sourceware.org
Subject: Re: gas section alignment less than 4 bytes
Date: Tue, 4 Jul 2023 12:08:08 +0100	[thread overview]
Message-ID: <f5fe9e22-b899-19cd-11e4-55768e0b0f01@redhat.com> (raw)
In-Reply-To: <abee4dee-c897-4107-9e78-4f7b4ebb8cce@freesbee.fr>

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


      parent reply	other threads:[~2023-07-04 11:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03 20:56 Vincent Rivière
2023-07-03 21:03 ` Andreas Schwab
2023-07-04 11:08 ` Nick Clifton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5fe9e22-b899-19cd-11e4-55768e0b0f01@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=vincent.riviere@freesbee.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).