[llvm] 231ef21 - [MC][ARM] Fix redundant errors for .quad/.8byte relocations on ELF

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun May 7 21:41:43 PDT 2023


Author: Fangrui Song
Date: 2023-05-07T21:41:38-07:00
New Revision: 231ef2104d15c306f0e362db649cf241ac575d09

URL: https://github.com/llvm/llvm-project/commit/231ef2104d15c306f0e362db649cf241ac575d09
DIFF: https://github.com/llvm/llvm-project/commit/231ef2104d15c306f0e362db649cf241ac575d09.diff

LOG: [MC][ARM] Fix redundant errors for .quad/.8byte relocations on ELF

For a .quad/.8byte directive that needs a relocation, Mach-O emits one error
while ELF emits two. Emit just one for ELF and change the diagnostic to match
other ports.

Added: 
    

Modified: 
    llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
    llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
    llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
    llvm/test/MC/ARM/arm-memory-instructions-immediate.s
    llvm/test/MC/ARM/quad-relocation.s
    llvm/test/MC/ARM/t2-modified-immediate-fixup-error1.s
    llvm/test/MC/ARM/thumb1-relax-adr.s
    llvm/test/MC/ARM/thumb1-relax-bcc.s
    llvm/test/MC/ARM/thumb1-relax-br.s
    llvm/test/MC/ARM/thumb1-relax-ldrlit.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
index 0bd715688b018..df142b85256eb 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
@@ -448,7 +448,6 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
 
   switch (Kind) {
   default:
-    Ctx.reportError(Fixup.getLoc(), "bad relocation fixup type");
     return 0;
   case FK_Data_1:
   case FK_Data_2:

diff  --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
index df8f54d14a869..2a6bda6ccd810 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
@@ -87,7 +87,7 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
   if (IsPCRel) {
     switch (Fixup.getTargetKind()) {
     default:
-      Ctx.reportError(Fixup.getLoc(), "unsupported relocation on symbol");
+      Ctx.reportError(Fixup.getLoc(), "unsupported relocation type");
       return ELF::R_ARM_NONE;
     case FK_Data_4:
       switch (Modifier) {
@@ -159,7 +159,7 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
   }
   switch (Kind) {
   default:
-    Ctx.reportError(Fixup.getLoc(), "unsupported relocation on symbol");
+    Ctx.reportError(Fixup.getLoc(), "unsupported relocation type");
     return ELF::R_ARM_NONE;
   case FK_Data_1:
     switch (Modifier) {

diff  --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
index b26773099a886..6f81205f7a32e 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
@@ -79,7 +79,7 @@ static bool getARMFixupKindMachOInfo(unsigned Kind, unsigned &RelocType,
     return true;
   case FK_Data_8:
     Log2Size = llvm::Log2_32(8);
-    return true;
+    return false;
 
     // These fixups are expected to always be resolvable at assembly time and
     // have no relocations supported.
@@ -386,8 +386,7 @@ void ARMMachObjectWriter::recordRelocation(MachObjectWriter *Writer,
     // relocation type for the fixup kind. This happens when it's a fixup that's
     // expected to always be resolvable at assembly time and not have any
     // relocations needed.
-    Asm.getContext().reportError(Fixup.getLoc(),
-                                 "unsupported relocation on symbol");
+    Asm.getContext().reportError(Fixup.getLoc(), "unsupported relocation type");
     return;
   }
 

diff  --git a/llvm/test/MC/ARM/arm-memory-instructions-immediate.s b/llvm/test/MC/ARM/arm-memory-instructions-immediate.s
index 04b2b9e08a26e..d72028edc9e21 100644
--- a/llvm/test/MC/ARM/arm-memory-instructions-immediate.s
+++ b/llvm/test/MC/ARM/arm-memory-instructions-immediate.s
@@ -21,5 +21,5 @@ foo:
 // CHECK-NEXT: strb r0, [r1, #1024]
 .ifdef ERR
     str r0, [r1, 1b]
-// ERR:[[#@LINE-1]]:5: error: unsupported relocation on symbol
+// ERR:[[#@LINE-1]]:5: error: unsupported relocation type
 .endif

diff  --git a/llvm/test/MC/ARM/quad-relocation.s b/llvm/test/MC/ARM/quad-relocation.s
index 34de182924e28..50d8d82be5843 100644
--- a/llvm/test/MC/ARM/quad-relocation.s
+++ b/llvm/test/MC/ARM/quad-relocation.s
@@ -1,9 +1,9 @@
-@ RUN: not llvm-mc -triple arm-arm-none-eabi -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
+@ RUN: not llvm-mc -triple=arm -filetype=obj %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
+@ RUN: not llvm-mc -triple=arm-apple-darwin -filetype=obj %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
 
 	.align 3
 symbol:
-  .quad(symbol)
-
-@ CHECK: error: unsupported relocation on symbol
-@ CHECK-NEXT:   .quad(symbol)
-@ CHECK-NEXT:        ^
+@ CHECK:      :[[#@LINE+1]]:6: error: unsupported relocation type
+.quad(symbol)
+@ CHECK:      :[[#@LINE+1]]:8: error: unsupported relocation type
+.8byte symbol

diff  --git a/llvm/test/MC/ARM/t2-modified-immediate-fixup-error1.s b/llvm/test/MC/ARM/t2-modified-immediate-fixup-error1.s
index f5113a6492077..642484080b1c0 100644
--- a/llvm/test/MC/ARM/t2-modified-immediate-fixup-error1.s
+++ b/llvm/test/MC/ARM/t2-modified-immediate-fixup-error1.s
@@ -10,4 +10,4 @@
     .equ sym0, 0x01abcdef
 .L2:
     mov r0, .L2
-@ CHECK: error: unsupported relocation on symbol
+@ CHECK: :[[#@LINE-1]]:5: error: unsupported relocation type

diff  --git a/llvm/test/MC/ARM/thumb1-relax-adr.s b/llvm/test/MC/ARM/thumb1-relax-adr.s
index 3eb2a02ad1f47..fc5c7c39df5ae 100644
--- a/llvm/test/MC/ARM/thumb1-relax-adr.s
+++ b/llvm/test/MC/ARM/thumb1-relax-adr.s
@@ -5,4 +5,4 @@
         .global func1
 _func1:
         adr r0, _func2
-@ CHECK-ERROR: unsupported relocation on symbol
+@ CHECK-ERROR: :[[#@LINE-1]]:9: error: unsupported relocation type

diff  --git a/llvm/test/MC/ARM/thumb1-relax-bcc.s b/llvm/test/MC/ARM/thumb1-relax-bcc.s
index 0d73a0067925b..78f3477c19710 100644
--- a/llvm/test/MC/ARM/thumb1-relax-bcc.s
+++ b/llvm/test/MC/ARM/thumb1-relax-bcc.s
@@ -5,7 +5,7 @@
 
         .global func1
 _func1:
-@ CHECK-ERROR: :[[#@LINE+1]]:9: error: unsupported relocation on symbol
+@ CHECK-ERROR: :[[#@LINE+1]]:9: error: unsupported relocation type
         bne _func2
 
 @ CHECK-ELF: f47f affe          bne.w {{.+}} @ imm = #-4

diff  --git a/llvm/test/MC/ARM/thumb1-relax-br.s b/llvm/test/MC/ARM/thumb1-relax-br.s
index 5652073587e9e..b58dd6c0b413c 100644
--- a/llvm/test/MC/ARM/thumb1-relax-br.s
+++ b/llvm/test/MC/ARM/thumb1-relax-br.s
@@ -9,8 +9,7 @@ _func1:
         @ There is no MachO relocation for Thumb1's unconditional branch, so
         @ this is unrepresentable. FIXME: I think ELF could represent this.
         b _func2
-
-@ CHECK-ERROR: unsupported relocation on symbol
+@ CHECK-ERROR: :[[#@LINE-1]]:9: error: unsupported relocation type
 
 @ CHECK-MACHO: f7ff bffe          b.w {{.+}} @ imm = #-4
 @ CHECK-MACHO-NEXT: ARM_THUMB_RELOC_BR22

diff  --git a/llvm/test/MC/ARM/thumb1-relax-ldrlit.s b/llvm/test/MC/ARM/thumb1-relax-ldrlit.s
index 31a9759104df5..5cba3690f1feb 100644
--- a/llvm/test/MC/ARM/thumb1-relax-ldrlit.s
+++ b/llvm/test/MC/ARM/thumb1-relax-ldrlit.s
@@ -4,5 +4,5 @@
 
         .global func1
 _func1:
-@ CHECK-ERROR: :[[#@LINE+1]]:9: error: unsupported relocation on symbol
+@ CHECK-ERROR: :[[#@LINE+1]]:9: error: unsupported relocation type
         ldr r0, _func2


        


More information about the llvm-commits mailing list