[llvm] 4ba0061 - [llvm-readobj/elf] - Fix the PREL31 relocation computation used for dumping arm32 unwind info (-u).

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 06:23:16 PDT 2020


Author: Georgii Rymar
Date: 2020-09-28T16:22:56+03:00
New Revision: 4ba00619ee70be6eda1d6fbd37471636145d1140

URL: https://github.com/llvm/llvm-project/commit/4ba00619ee70be6eda1d6fbd37471636145d1140
DIFF: https://github.com/llvm/llvm-project/commit/4ba00619ee70be6eda1d6fbd37471636145d1140.diff

LOG: [llvm-readobj/elf] - Fix the PREL31 relocation computation used for dumping arm32 unwind info (-u).

This is a part of https://bugs.llvm.org/show_bug.cgi?id=47581.

We have the following computation:
```
(1) uint64_t Location = Address & 0x7fffffff;
(2) if (Location & 0x04000000)
(3)   Location |= (uint64_t) ~0x7fffffff;
(4) return Location + Place;
```

At line 2 there is a mistype. The constant should be `0x40000000`,
not `0x04000000`, because the intention here is to sign extend the `Location`,
which is the 31 bit signed value.

Differential revision: https://reviews.llvm.org/D88407

Added: 
    

Modified: 
    llvm/test/tools/llvm-readobj/ELF/ARM/unwind-non-relocatable.test
    llvm/tools/llvm-readobj/ARMEHABIPrinter.h

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-readobj/ELF/ARM/unwind-non-relocatable.test b/llvm/test/tools/llvm-readobj/ELF/ARM/unwind-non-relocatable.test
index 4748a044c1a3..8740fa1b342d 100644
--- a/llvm/test/tools/llvm-readobj/ELF/ARM/unwind-non-relocatable.test
+++ b/llvm/test/tools/llvm-readobj/ELF/ARM/unwind-non-relocatable.test
@@ -48,6 +48,17 @@
 # UNWIND-NEXT:         FunctionAddress: 0x24C
 # UNWIND-NEXT:         Model: CantUnwind
 # UNWIND-NEXT:       }
+# UNWIND-NEXT:       Entry {
+# UNWIND-NEXT:         FunctionAddress: 0x4000026B
+# UNWIND-NEXT:         FunctionName: func4
+# UNWIND-NEXT:         Model: Compact (Inline)
+# UNWIND-NEXT:         PersonalityIndex: 0
+# UNWIND-NEXT:         Opcodes [
+# UNWIND-NEXT:           0xB0      ; finish
+# UNWIND-NEXT:           0xB0      ; finish
+# UNWIND-NEXT:           0xB0      ; finish
+# UNWIND-NEXT:         ]
+# UNWIND-NEXT:       }
 # UNWIND-NEXT:     ]
 # UNWIND-NEXT:   }
 # UNWIND-NEXT: }
@@ -78,6 +89,9 @@ Sections:
 ## Address of .ARM.exidx (0x24C) + entry offset (24) + 0x7fffffe8 (31 bit) == 0x24C.
       - Offset: 0x7FFFFFE8
         Value:  EXIDX_CANTUNWIND
+## Address of .ARM.exidx (0x24C) + entry offset (32) + 0x3FFFFFFF (31 bit) == 0x4000026b.
+      - Offset: 0x3FFFFFFF
+        Value:  0x80B0B0B0 ## arbitrary opcodes.
 Symbols:
   - Name:    func1
     Type:    STT_FUNC
@@ -91,3 +105,7 @@ Symbols:
     Type:    STT_FUNC
     Section: .text
     Value:   0x248
+  - Name:    func4
+    Type:    STT_FUNC
+    Section: .text
+    Value:   0x4000026b

diff  --git a/llvm/tools/llvm-readobj/ARMEHABIPrinter.h b/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
index e4ac16a882c7..c91d57ca2626 100644
--- a/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
+++ b/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
@@ -336,7 +336,7 @@ class PrinterContext {
 
   static uint64_t PREL31(uint32_t Address, uint32_t Place) {
     uint64_t Location = Address & 0x7fffffff;
-    if (Location & 0x04000000)
+    if (Location & 0x40000000)
       Location |= (uint64_t) ~0x7fffffff;
     return Location + Place;
   }


        


More information about the llvm-commits mailing list