This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Emit a diagnostic if there's reference to a local symbol in a discarded COMDAT section
AbandonedPublic

Authored by davide on Sep 22 2016, 11:53 AM.

Details

Reviewers
ruiu
rafael
Summary

Continuing the discussion from: https://reviews.llvm.org/D24750

Diff Detail

Event Timeline

davide updated this revision to Diff 72198.Sep 22 2016, 11:53 AM
davide retitled this revision from to [ELF] Emit a diagnostic if there's reference to a local symbol in a discarded COMDAT section.
davide updated this object.
davide added reviewers: ruiu, rafael.
davide added a subscriber: llvm-commits.
ruiu edited edge metadata.Sep 22 2016, 12:48 PM

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.

rafael edited edge metadata.Sep 23 2016, 11:06 AM

Is this producing a warning for know broken special cases like .eh_frame and .debug_line?

Is this producing a warning for know broken special cases like .eh_frame and .debug_line?

Yes, do we want to skip them?

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.

davide abandoned this revision.Oct 17 2016, 7:47 PM