[PATCH] D84001: [ELF] Allow mixed SHF_LINK_ORDER & non-SHF_LINK_ORDER sections and sort within InputSectionDescription

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 00:56:51 PDT 2020


jhenderson added a comment.

This is definitely an improvement from my point of view, so in general +1 from me.

FWIW, this doesn't help my specific use-case because all my debug sections have the same name, so can't be distinguished in linker scripts, but the ordering needs to be maintained the same as the input ordering, so I end up with a mix of ordered and unordered sections, which with this change would be allowed, but would end up with all the ordered ones first (and thus the underlying assumption would be broken). Example:

  .debug_info [common1]
  .debug_info [referencing .text.1]
  .debug_info [common2]
  .debug_info [referencing .text.2]
  ...

will end up as:

  .debug_info [.text.1]
  .debug_info [.text.2]
  .debug_info [common1]
  .debug_info [common2]

which will not be a valid structure. Anyway, I don't think there's anything that can be done here without disabling the sorting entirely.



================
Comment at: lld/test/ELF/linkerscript/linkorder.s:56
+# RUN: ld.lld -T %t4.lds %t.o -o %t4
+# RUN: llvm-readelf -S -x .rodata %t4 | FileCheck --check-prefix=CHECK4 %s
+
----------------
You don't use the section header dump here. Can you get rid of `-S`?


================
Comment at: lld/test/ELF/linkerscript/linkorder.s:59
+# CHECK4:      Hex dump of section '.rodata':
+# CHECK4-NEXT: 01cccccc 0302
 
----------------
I'm either missing something, or something odd is going on here. Where are the `cccccc` coming from? There doesn't appear to be a .text section with any contents - it has the _start symbol in, if I follow correctly, but should be empty; nothing specifies alignment requirements either here.


================
Comment at: lld/test/ELF/linkerscript/linkorder.s:69-70
 
 .section .ro,"a"
 .byte 0
 
----------------
This section doesn't seem to be being used?


================
Comment at: lld/test/ELF/linkerscript/linkorder.s:78-79
 .byte 1
+## If the two .rodata.bar sections are in the same InputSectionDescription,
+## 03 (sh_link!=0) will be ordered before 02 (sh_link=0).
+.section .rodata.bar,"a", at progbits
----------------
It seems to me like you need test cases for sh_link=0 for SHF_LINK_ORDER sections here too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84001





More information about the llvm-commits mailing list