This is an archive of the discontinued LLVM Phabricator instance.

Fix PR23871: Passing a string literal to .byte directive crashes the assembler
AbandonedPublic

Authored by enefaim on Sep 30 2015, 10:06 AM.

Details

Summary

Passing a string literal to .byte directive crashes LLVM when assembling for AArch64 target.

Output:
Unknown ELF relocation type
UNREACHABLE executed at /home/bgabor/work/clang-driver/byte-directive/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp:244!

This patch replaces the crash with an error message like the test-case in test/MC/ARM/Windows/invalid-relocation.s

Diff Detail

Repository
rL LLVM

Event Timeline

enefaim updated this revision to Diff 36122.Sep 30 2015, 10:06 AM
enefaim retitled this revision from to Fix PR23871: Passing a string literal to .byte directive crashes the assembler.
enefaim updated this object.
enefaim set the repository for this revision to rL LLVM.
enefaim added a subscriber: llvm-commits.
test/MC/AArch64/invalid-relocation.s
6

Wouldn't a nice error message be to output the string rather than an internal enum type?

Hi Richard,

I agree that emitting source line information instead of the internal enum type would be
much better here. I just don't know how to get that information in the context of the code
in question.

Hi Saleem,

I was told that you have a good understanding of this part of LLVM.
Could you take a look at this patch?

Thanks,
Gabor Ballabas

Hi Gabor,

Can you explain the relation between the "a" parameter and the relocation FK_Dtata_1?

Can you correlate that enum type to the ARM ABI name?

Also, why do we need a special unsupported message for that relocation type only? The design of that switch clearly states that unsupported types are to break the compilation. If we start treating special relocation types with different behaviour, the code will become harder to maintain.

A better approach would be to either fail earlier (if that syntax is incorrect) in the assembler parser. Or, if the syntax *is* correct, to implement support for that relocation type (or use the correct relocation, if that's also wrong).

cheers,
--renato

compnerd edited edge metadata.Oct 7 2015, 7:59 PM

This really is the wrong way to handle this. .byte shouldn't accept the string literal in the first place. This should be diagnosed in the AsmParser. I can take a look at that if you like.

enefaim abandoned this revision.Jan 20 2017, 9:28 AM

Abandoning this revision because it has been fixed in another revision.
See details: https://llvm.org/bugs/show_bug.cgi?id=23871