https://sourceware.org/bugzilla/show_bug.cgi?id=31415
Bug ID: 31415 Summary: Section coalescing should ignore (and merge) SHF_GNU_RETAIN Product: binutils Version: 2.43 (HEAD) Status: UNCONFIRMED Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: alast...@alastairs-place.net CC: ian at airs dot com Target Milestone: --- In layout.cc, the code avoids combining sections whose flags differ, while ignoring `SHF_WRITE` and `SHF_EXECINSTR`. (This seems an odd choice, frankly; those are the flags I probably *wouldn't* want to ignore.) Unfortunately, it doesn't ignore `SHF_GNU_RETAIN`; this is a particularly awkward problem because programs tend to use `SHF_GNU_RETAIN` when they're storing data in a section and using the linker-generated `__start` and `__stop` symbols to access it. Since the latter are not regarded as GC roots, the retain flag is needed to stop the linker discarding the section, *but* if any object file in the link doesn't have `SHF_GNU_RETAIN` set for that section, then `gold` will generate another output section, with the same name, but of course there's only one `__start` and `__stop` symbol pair and it only points at a single section. It seems to me that: 1. `gold` should ignore `SHF_GNU_RETAIN` when looking up sections to coalesce, but 2. If it finds a section with `SHF_GNU_RETAIN` and coalesces it with a section that did not have that flag, the resulting section *should* have the flag set. i.e. setting it on *any* input section that gets coalesced into an output section should cause it to be set for the output section. -- You are receiving this mail because: You are on the CC list for the bug.