[PATCH] D74927: [MC][ARM] make Thumb function also if type attribute is set

Stefan Agner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 20 13:26:01 PST 2020


falstaff84 created this revision.
falstaff84 added reviewers: psmith, DavidSpickett.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls.
Herald added a project: LLVM.

Make sure to set the bottom bit of the symbol even when the type
attribute of a label is set after the label.

This fixes:
https://bugs.llvm.org/show_bug.cgi?id=44860


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74927

Files:
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/test/MC/ARM/thumb-function-address.s


Index: llvm/test/MC/ARM/thumb-function-address.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ARM/thumb-function-address.s
@@ -0,0 +1,20 @@
+@ RUN: llvm-mc -filetype=obj -triple=armv7-linux-gnueabi %s -o %t
+@ RUN: llvm-readobj --symbols %t | FileCheck %s
+
+  .syntax unified
+  .text
+  .thumb
+func_label:
+  .type func_label, %function
+
+@ Check func_label address has bit 1 set.
+@ CHECK:   Symbol {
+@ CHECK:     Name: func_label (7)
+@ CHECK:     Value: 0x1
+@ CHECK:     Size: 0
+@ CHECK:     Binding: Local (0x0)
+@ CHECK:     Type: Function (0x2)
+@ CHECK:     Other: 0
+@ CHECK:     Section: .text (0x2)
+@ CHECK:   }
+
Index: llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
===================================================================
--- llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -587,6 +587,20 @@
     }
   }
 
+  bool EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
+    bool val = MCELFStreamer::EmitSymbolAttribute(S, Attribute);
+
+    if (!IsThumb)
+      return val;
+
+    auto *Symbol = cast<MCSymbolELF>(S);
+    unsigned Type = cast<MCSymbolELF>(Symbol)->getType();
+    if (Type == ELF::STT_FUNC || Type == ELF::STT_GNU_IFUNC)
+      getAssembler().setIsThumbFunc(Symbol);
+
+    return val;
+  };
+
 private:
   enum ElfMappingSymbol {
     EMS_None,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74927.245729.patch
Type: text/x-patch
Size: 1423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200220/8d2c0c04/attachment.bin>


More information about the llvm-commits mailing list