[PATCH] D13298: Fix PR23871: Passing a string literal to .byte directive crashes the assembler

Gabor Ballabas via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 10:06:41 PDT 2015


enefaim created this revision.
enefaim added reviewers: richard.barton.arm, kristof.beyls.
enefaim added a subscriber: llvm-commits.
enefaim set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.

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

Repository:
  rL LLVM

http://reviews.llvm.org/D13298

Files:
  lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
  test/MC/AArch64/invalid-relocation.s

Index: test/MC/AArch64/invalid-relocation.s
===================================================================
--- /dev/null
+++ test/MC/AArch64/invalid-relocation.s
@@ -0,0 +1,6 @@
+# RUN: not llvm-mc -triple aarch64-elf -filetype obj -o /dev/null 2>&1 %s \
+# RUN:     | FileCheck %s
+
+.byte("a")
+
+# CHECK: LLVM ERROR: unsupported relocation type: FK_Data_1
Index: lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
===================================================================
--- lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
+++ lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
@@ -61,6 +61,8 @@
 
   if (IsPCRel) {
     switch ((unsigned)Fixup.getKind()) {
+    case FK_Data_1:
+      report_fatal_error("unsupported relocation type: FK_Data_1");
     case FK_Data_2:
       return ELF::R_AARCH64_PREL16;
     case FK_Data_4:
@@ -97,6 +99,8 @@
     }
   } else {
     switch ((unsigned)Fixup.getKind()) {
+    case FK_Data_1:
+      report_fatal_error("unsupported relocation type: FK_Data_1");
     case FK_Data_2:
       return ELF::R_AARCH64_ABS16;
     case FK_Data_4:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13298.36122.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150930/cc1a3764/attachment.bin>


More information about the llvm-commits mailing list