From: Fangrui Song <i@maskray.me>
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org, bd1976llvm@gmail.com
Subject: Re: .section directives with the same name but different fields
Date: Thu, 06 Feb 2020 09:19:00 -0000 [thread overview]
Message-ID: <20200206091914.5docw46nvgx7om6o@google.com> (raw)
In-Reply-To: <20200206083347.GC5669@bubble.grove.modra.org>
On 2020-02-06, Alan Modra wrote:
>On Wed, Feb 05, 2020@11:38:37PM -0800, Fangrui Song wrote:
>> ## Different sh_entsize
>>
>> .section .foo,"aM",@progbits,4
>> .section .foo,"aM",@progbits,8
>>
>> GNU as emits a warning `Warning: ignoring changed section entity size for .foo`
>
>I think this one probably should be an error rather than a warning.
An error is fine, but it can bring up some implementation difficulties.
If an implementation does a one-pass scan over global variables to
emit .section directives and variable labels, it may not know sh_entsize
when it is about the emit the first .section directive.
>> The output sh_entsize is 4. If the second .section defines an object, the object may get corrupted after merging
>> (https://bugs.llvm.org/show_bug.cgi?id=43457 )
>> For this case, we have several choices:
>>
>> 1. (Status quo) Emit one section. Set sh_entsize to 4 and emit a warning.
>> 2. Emit two sections, i.e. sh_entsize is a differentiator.
>
>If you do, the linker won't do merging of values for those sections.
>
>> 3. Emit one section. Set sh_entsize to 0. Should the assembler emit a warning?
>
>And remove SHF_MERGE too I guess. That's an option but I think it's
>better just to error.
>
>>
>> ## Different sh_flags
>>
>> .section .foo,"aw"
>> .section .foo,"a" # Warning: ignoring changed section attributes for .foo
>>
>> Shall we emit two sections?
>
>I don't think so. User assembly often gets section attributes wrong
>or leaves them off entirely for special sections known to the
>assembler. ie. the first .section .foo above is a built-in rather
>than user input.
>
>>
>> ## Different sh_type
>>
>> .section .foo,"a",@progbits
>> .section .foo,"a",@nobits # Warning: ignoring changed section type for .foo
>>
>> Shall we emit two sections?
>
>Again we should continue to handle the case where .foo is a special
>section of known type. So I think a warning rather than creating two
>sections is appropriate.
Do you think the warnings should be upgraded to errors (for sh_flags and
sh_type)?
next prev parent reply other threads:[~2020-02-06 9:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-06 7:38 Fangrui Song
2020-02-06 8:33 ` Alan Modra
2020-02-06 9:19 ` Fangrui Song [this message]
2020-02-06 14:09 ` Alan Modra
2020-02-06 17:25 ` bd1976 llvm
2020-02-10 5:21 ` Alan Modra
2020-03-03 21:20 ` Empty section flags Fangrui Song
2020-04-04 14:17 ` H.J. Lu
2020-04-04 16:38 ` Fangrui Song
2020-04-04 16:45 ` H.J. Lu
2020-04-13 21:32 ` Fangrui Song
[not found] ` <CAN30aBGpQecmszv-JsZwVTNrOTW0dGt4zUjas7Cx6b-B3XwjgQ@mail.gmail.com>
2020-04-04 0:43 ` Fangrui Song
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=20200206091914.5docw46nvgx7om6o@google.com \
--to=i@maskray.me \
--cc=amodra@gmail.com \
--cc=bd1976llvm@gmail.com \
--cc=binutils@sourceware.org \
/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).