This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
.section directives with the same name but different fields
- From: Fangrui Song <i at maskray dot me>
- To: binutils at sourceware dot org
- Cc: bd1976llvm at gmail dot com
- Date: Wed, 5 Feb 2020 23:38:37 -0800
- Subject: .section directives with the same name but different fields
## Different group signature
.section .foo,"aG",@progbits,foo
.section .foo,"aG",@progbits,bar
Both GNU as and llvm-mc (usage: llvm-mc -filetype=obj a.s -o a.o) create
two sections.
We don't want to change this rule.
## Different sh_link
foo:
bar:
.section .foo,"ao",@progbits,foo
.section .foo,"ao",@progbits,bar
With H.J. Lu's https://sourceware.org/ml/binutils/2020-02/msg00028.html ,
GNU as emits two sections, even if foo and bar are defined in the same section.
This is something both GNU as and llvm-mc (https://reviews.llvm.org/D74006) want to do.
Also see https://bugs.llvm.org/show_bug.cgi?id=44775
Now, something that needs discussion.
## 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`
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.
3. Emit one section. Set sh_entsize to 0. Should the assembler emit a warning?
## Different sh_flags
.section .foo,"aw"
.section .foo,"a" # Warning: ignoring changed section attributes for .foo
Shall we emit two sections?
## Different sh_type
.section .foo,"a",@progbits
.section .foo,"a",@nobits # Warning: ignoring changed section type for .foo
Shall we emit two sections?
## Different sh_addr,sh_offset,sh_size,sh_info,sh_addralign
These fields are not specified by the .section directive, thus they
should not be a differentiator.