[PATCH] D70020: [lld] Better support for group semantic wrt. notes
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 17:41:02 PST 2019
MaskRay added a comment.
> Better support for group semantic wrt. notes
>
> This is needed both to respect the group semantic and for the annobin tool (see
"to respect the group semantic" is not accurate. The ELF specification does not have such rules. I think this is more of a GNU ld --gc-sections semantic (not even implemented in gold). It seems that when GNU ld decides to discard a SHF_ALLOC section in a comdat group, it discards non-SHF_ALLOC sections in the group as well. The section type does not seem to matter. If we rename `.note..text.foo` (is double-dot `..` the intention?) to `.aaa`, and change its type from SHT_NOTE to SHT_PROGBITS, we will get the same observations. Knowing the rules used by GNU ld will be helpful.
================
Comment at: lld/test/ELF/sht-group-note.test:1
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t0 --gc-sections
----------------
A file-level comment that describes the purpose.
Perhaps rename the test to `gc-sections-group.s`
================
Comment at: lld/test/ELF/sht-group-note.test:34
+ Content: "DEAD"
+ - Name: .text.foo
+ Type: SHT_PROGBITS
----------------
Add `Content: "00"`
GNU ld discards empty sections. A non-empty .text.foo makes it easy to compare the linkers' behaviors.
================
Comment at: lld/test/ELF/sht-group-note.test:37
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
+ - Name: .rela.text.foo
+ Type: SHT_RELA
----------------
.rela.text.foo is unrelated and can be deleted.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70020/new/
https://reviews.llvm.org/D70020
More information about the llvm-commits
mailing list