public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* .section directives with the same name but different fields
@ 2020-02-06  7:38 Fangrui Song
  2020-02-06  8:33 ` Alan Modra
  0 siblings, 1 reply; 12+ messages in thread
From: Fangrui Song @ 2020-02-06  7:38 UTC (permalink / raw)
  To: binutils; +Cc: bd1976llvm

## 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.

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

end of thread, other threads:[~2020-04-13 21:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06  7:38 .section directives with the same name but different fields Fangrui Song
2020-02-06  8:33 ` Alan Modra
2020-02-06  9:19   ` Fangrui Song
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

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).