[PATCH] D34650: [COFF] Allow debug info to relocate against discarded symbols

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 15:40:01 PDT 2017


rnk added inline comments.


================
Comment at: lld/COFF/Chunks.cpp:56-66
+static void applySecRel(const SectionChunk *Sec, uint8_t *Off,
+                        OutputSection *OS, uint64_t S) {
+  if (!OS) {
+    if (Sec->isCodeView())
+      return;
+    fatal("SECREL relocation cannot be applied to absolute symbols");
+  }
----------------
ruiu wrote:
> Ah, this is much more elegant than I was thinking. Good job!
Thanks!


================
Comment at: lld/COFF/MarkLive.cpp:57
+    // This can happen if the input object files have relocations against
+    // discarded sections. This is invalid input, but it is a common error.
+    if (SC->isDiscarded())
----------------
ruiu wrote:
> ... a common error in debug sections?
I guess this is a bad comment. It's more that I didn't want to duplicate the error message in two places when we can just continue here.

Concretely, we need this code because if we don't have it, we will fail the next assert, because isLive() is defined as:
  return Live && !Discarded;


================
Comment at: lld/test/COFF/reloc-discarded.s:28
+main:
+	movq assoc_global(%rip), %rax
+	movl (%rax), %eax
----------------
This is the invalid input test that shows how to get into this situation, FWIW.


https://reviews.llvm.org/D34650





More information about the llvm-commits mailing list