[PATCH] gas: Document @ and % as interchangeable for type argument in .section

Will Hawkins hawkinsw@obs.cr
Mon May 18 13:00:48 GMT 2026


On Mon, May 18, 2026 at 1:57 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 17.05.2026 13:35, Will Hawkins wrote:
> > On Sunday, May 17, 2026, Will Hawkins <hawkinsw@obs.cr> wrote:
> >> On Sunday, May 17, 2026, Jan Beulich <jbeulich@suse.com> wrote:
> >>> On 16.05.2026 02:38, Will Hawkins wrote:
> >>>> In the .section Assembler Directive for the ELF format, both the % and
> >>>> the @ can be used when writing the type argument.
> >>>
> >>> That's not exactly true (the two aren't fully interchangeable), and hence
> >>> ...
> >>
> >>
> >>
> >> In obj-elf.c, I saw
> >>
> >> else if (c == '@' || c == '%')
> >>
> >> which I must have misinterpreted?
> >
> > I guess that they are only treated equivalently in code on platforms where
> > the @ and % do not have implications for the code in earlier processing
> > before reaching obj_elf_section.
>
> Correct, comments are being removed much earlier. (If they were fully

I am glad that my reading of the code was not wildly inaccurate: _If_
there were no preprocessor implications for those characters, then
they would be equivalent.

> equivalent, in that testcase of yours you also wouldn't have had to
> switch from @ to %.)

Yes, I agree.

Before I propose an alternate, I figured it might be worth describing
why I wanted to make the change in the first place:

My local system is an x86-64. When I started developing a test case
for objdump and I was running the testsuite, the test in objdump.exp
based on the code in dw5-op.S passed. I could read the documentation
and see that @progbits should be the syntax.

I interpreted the existing note to imply mutually exclusive options
for @ vs %. And yet the test was passing. I used as to compile it --
just to be sure. Once I dug into the code and saw the aforementioned
if statement, I realized _why_ the test author used %: because % is
not a comment indicator on x86-64, using the % means that one version
of the test code works for both x86-64 and ARM platforms.

I proposed the change so that others would not have to search as much
as I did. With that as background, would you be amenable to rewriting

Note on targets where the @ character is the start of a comment (eg
ARM) then another character is used instead. For example the ARM port
uses the % character.

to

Note - certain targets treat @ as the start of a comment (e.g., ARM).
On such platforms, % is used instead. On platforms where neither @ nor
% indicate the start of a comment, @ and % may be used
interchangeably.

I hope that my (albeit modest) efforts at helping "future me" by
updating the docs are helpful. If they are not, please tell me!

Will

>
> Jan


More information about the Binutils mailing list