[PATCH] D84131: [ELF] Support -r --gc-sections

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 00:34:10 PDT 2020


jhenderson added inline comments.


================
Comment at: lld/ELF/InputFiles.cpp:947-948
+    // This section contains relocation information.
+    // If -r is given, we do not interpret or apply relocation
+    // but just copy relocation sections to output.
+    if (config->relocatable) {
----------------
Whilst you're moving this comment, some grammar fixes:

apply relocation -> apply relocations
to output -> to the output


================
Comment at: lld/ELF/InputFiles.cpp:951-955
+      // We want to add a dependency to target, similar like we do for
+      // -emit-relocs below. This is useful for the case when linker script
+      // contains the "/DISCARD/". It is perhaps uncommon to use a script with
+      // -r, but we faced it in the Linux kernel and have to handle such case
+      // and not to crash.
----------------
similar like we -> like we
for the case when linker script -> when a linker script
the "/DISCARD/" -> a "/DISCARD/" output section
have to handle such case and not to crash -> have to handle such cases without crashing


================
Comment at: lld/test/ELF/relocatable-gc.s:6-7
+
+## By default all regular sections are discarded. Only group signature symbols
+## and STT_SECTION symbols are emitted.
+# RUN: ld.lld -r --gc-sections --print-gc-sections %t.o -o %t
----------------
I'm not sure I follow from this why group signature symbols and STT_SECTION symbols are kept? I think this explanation needs expanding.


================
Comment at: lld/test/ELF/relocatable-gc.s:20
+
+## -u keeps .text.bar alive. Other members are kept alive as well.
+# RUN: ld.lld -r --gc-sections -u bar %t.o -o - | llvm-readelf -Ss - | \
----------------
"Other group members"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84131/new/

https://reviews.llvm.org/D84131





More information about the llvm-commits mailing list