Continuing the discussion from: https://reviews.llvm.org/D24750
Diff Detail
Event Timeline
This patch adds an error check but the erroneous relocations are processed as before. The relocations points to the Discarded section, so I think the latter process cannot handle them properly. How did it work in the first place?
I'm not sure it did. This is the disassembly of the generated lld output (in particular the second callq).
Disassembly of section .text2: foo: 1000: 90 nop Disassembly of section bar: bar: 1001: e8 fa ff ff ff callq -6 <foo> 1006: e8 f5 ef ff ff callq -4107
This is, instead, what gold generates:
./patatino: file format elf64-x86-64 Disassembly of section .text2: 00000000000001c4 <foo>: 1c4: 90 nop Disassembly of section bar: 00000000000001c5 <bar>: 1c5: e8 fa ff ff ff callq 1c4 <foo> 1ca: e8 31 fe ff ff callq 0 <foo-0x1c4>
I'm not quite sure we ought to produce a valid output, given that the input is not a valid ELF.
IMHO, emitting this warning is a good idea as it informs people that their object are not ELF-compliant. I also think it's very unfortunate we can't turn this into an error (at least not in its current form) because .eh_frame relies on this behavior to work correctly.
Is this producing a warning for know broken special cases like .eh_frame and .debug_line?
I think that when we arrive at this point we don't have anymore this information (if it comes from .eh_frame or something else), so we might need to record this earlier.