Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

A fatal error about -update-debug-sections #308

Closed
CcWeapon opened this issue Nov 7, 2022 · 3 comments
Closed

A fatal error about -update-debug-sections #308

CcWeapon opened this issue Nov 7, 2022 · 3 comments

Comments

@CcWeapon
Copy link

CcWeapon commented Nov 7, 2022

When I wanted to use -update-debug-sections to keep the debug info, I encountered an error.

LLVM ERROR: Relocation type not implemented yet!
 #0 0x0000aaaace788474 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000aaaace7864dc SignalHandler(int) Signals.cpp:0:0
 #2 0x0000ffffb5f8c5c0 (linux-vdso.so.1+0x5c0)
 #3 0x0000ffffb5aabcd8 raise /build/glibc-70LW9c/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #4 0x0000ffffb5a98a28 abort /build/glibc-70LW9c/glibc-2.31/stdlib/abort.c:81:7
 #5 0x0000aaaace71cc94 llvm::report_fatal_error(llvm::Twine const&, bool) (~/bolt/build/bin/llvm-bolt+0xb13c94)
 #6 0x0000aaaace71cde4 (~/bolt/build/bin/llvm-bolt+0xb13de4)
 #7 0x0000aaaace8a1e1c llvm::RuntimeDyldELF::resolveAArch64Relocation(llvm::SectionEntry const&, unsigned long, unsigned long, unsigned int, long) (~/bolt/build/bin/llvm-bolt+0xc98e1c)
 #8 0x0000aaaace891850 llvm::RuntimeDyldImpl::resolveRelocationList(llvm::SmallVector<llvm::RelocationEntry, 64u> const&, unsigned long) (~/bolt/build/bin/llvm-bolt+0xc88850)
 #9 0x0000aaaace8919e4 llvm::RuntimeDyldImpl::resolveLocalRelocations() (~/bolt/build/bin/llvm-bolt+0xc889e4)
#10 0x0000aaaace898b54 llvm::RuntimeDyldImpl::resolveRelocations() (~/bolt/build/bin/llvm-bolt+0xc8fb54)
#11 0x0000aaaace898d00 llvm::RuntimeDyld::finalizeWithMemoryManagerLocking() (~/bolt/build/bin/llvm-bolt+0xc8fd00)
#12 0x0000aaaace5c53b8 llvm::bolt::RewriteInstance::emitAndLink() (~/bolt/build/bin/llvm-bolt+0x9bc3b8)
#13 0x0000aaaace5ca0ec llvm::bolt::RewriteInstance::run() (~/bolt/build/bin/llvm-bolt+0x9c10ec)
#14 0x0000aaaacdef5fe4 main (~/bolt/build/bin/llvm-bolt+0x2ecfe4)
#15 0x0000ffffb5a98d50 __libc_start_main /build/glibc-70LW9c/glibc-2.31/csu/../csu/libc-start.c:342:3
#16 0x0000aaaacdf4addc _start (~/bolt/build/bin/llvm-bolt+0x341ddc)
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ~/bolt/build/bin/llvm-bolt libart-compiler.so -o libart-compiler.so.bolt -data=compiler.fdata -reorder-blocks=cache+ -reorder-functions=hfsort -split-eh -dyno-stats -update-debug-sections
Aborted (core dumped)

After the following temporary modification, the program can run properly. However, I think that it is unreasonable to modify llvm. You need to modify it.

As shown in the preceding figure, R_AARCH64_NONE in the section such as .rela.debug_loc is not processed in the current context. How do I process them?

diff --git a/cpu-bolt/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/cpu-bolt/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index 0de76ab78..4f54aa8d1 100644
--- a/cpu-bolt/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/cpu-bolt/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -420,7 +420,7 @@ void RuntimeDyldELF::resolveAArch64Relocation(const SectionEntry &Section,

   switch (Type) {
   default:
-    report_fatal_error("Relocation type not implemented yet!");
+    // report_fatal_error("Relocation type not implemented yet!");
     break;
   case ELF::R_AARCH64_ABS16: {
     uint64_t Result = Value + Addend;

The following figure shows the relocation information read from the elf file.

Relocation section '.rela.debug_loc' at offset 0x1855240 contains 205385 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000008  000000000000 R_AARCH64_NONE                       0
00000000004e  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 1be0f8
000000000094  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 1be0f8
0000000000dd  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 1be0f8
000000000123  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 1be0f8
000000000169  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 1be138
0000000001b2  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 1be17c
0000000001f8  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 14
000000000241  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 14
00000000028e  001600000101 R_AARCH64_ABS64   0000000000200000 .text + 14

****************************************************************************************************

There are 41 section headers, starting at offset 0xaec1a80:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .note.android.ide NOTE             0000000000000270  00000270
       0000000000000018  0000000000000000   A       0     0     4
  [ 2] .note.gnu.build-i NOTE             0000000000000288  00000288
       0000000000000020  0000000000000000   A       0     0     4
  [ 3] .dynsym           DYNSYM           00000000000002a8  000002a8
       0000000000018d38  0000000000000018   A       7     1     8
  [ 4] .gnu.version      VERSYM           0000000000018fe0  00018fe0
       000000000000211a  0000000000000002   A       3     0     2
  [ 5] .gnu.version_r    VERNEED          000000000001b0fc  0001b0fc
       0000000000000080  0000000000000000   A       7     4     4
  [ 6] .gnu.hash         GNU_HASH         000000000001b180  0001b180
       0000000000006bb8  0000000000000000   A       3     0     8
  [ 7] .dynstr           STRTAB           0000000000021d38  00021d38
       000000000004be98  0000000000000000   A       0     0     1
  [ 8] .rela.dyn         LOOS+0x2         000000000006dbd0  0006dbd0
       00000000000003d7  0000000000000001   A       3     0     8
  [ 9] .relr.dyn         00000013: <unkn  000000000006dfa8  0006dfa8
       00000000000005b0  0000000000000008   A       0     0     8
  [10] .rela.plt         RELA             000000000006e558  0006e558
       0000000000001da0  0000000000000018  AI       3    21     8
  [11] .eh_frame         PROGBITS         00000000000702f8  000702f8
       000000000003c224  0000000000000000   A       0     0     8
  [12] .rodata           PROGBITS         00000000000ac520  000ac520
       0000000000013141  0000000000000000 AMS       0     0     16
  [13] .eh_frame_hdr     PROGBITS         00000000000bf664  000bf664
       000000000000e6cc  0000000000000000   A       0     0     4
  [14] .text             PROGBITS         0000000000200000  00200000
       0000000000313f6c  0000000000000000  AX       0     0     4
  [15] .plt              PROGBITS         0000000000513f70  00513f70
       00000000000013e0  0000000000000000  AX       0     0     16
  [16] .data.rel.ro      PROGBITS         0000000000600000  00600000
       0000000000015918  0000000000000000  WA       0     0     8
  [17] .fini_array       FINI_ARRAY       0000000000615918  00615918
       0000000000000010  0000000000000000  WA       0     0     8
  [18] .init_array       INIT_ARRAY       0000000000615928  00615928
       0000000000000150  0000000000000000  WA       0     0     8
  [19] .dynamic          DYNAMIC          0000000000615a78  00615a78
       0000000000000280  0000000000000010  WA       7     0     8
  [20] .got              PROGBITS         0000000000615cf8  00615cf8
       0000000000000708  0000000000000000  WA       0     0     8
  [21] .got.plt          PROGBITS         0000000000616400  00616400
       00000000000009f8  0000000000000000  WA       0     0     8
  [22] .bss              NOBITS           0000000000816e00  00616e00
       0000000000007f00  0000000000000000  WA       0     0     16
  [23] .rela.text        RELA             0000000000000000  00616e00
       00000000001fc8c0  0000000000000018   I      38    14     8
  [24] .rela.data.rel.ro RELA             0000000000000000  008136c0
       000000000003b838  0000000000000018   I      38    16     8
  [25] .rela.fini_array  RELA             0000000000000000  0084eef8
       0000000000000030  0000000000000018   I      38    17     8
  [26] .debug_loc        PROGBITS         0000000000000000  0084ef28
       0000000001006314  0000000000000000           0     0     1
  [27] .rela.debug_loc   RELA             0000000000000000  01855240
       00000000004b36d8  0000000000000018   I      38    26     8
  [28] .debug_abbrev     PROGBITS         0000000000000000  01d08918
       0000000000057181  0000000000000000           0     0     1
  [29] .debug_info       PROGBITS         0000000000000000  01d5fa99
       000000000274de3d  0000000000000000           0     0     1
  [30] .rela.debug_info  RELA             0000000000000000  044ad8d8
       000000000447d848  0000000000000018   I      38    29     8
  [31] .debug_ranges     PROGBITS         0000000000000000  0892b120
       0000000000628e30  0000000000000000           0     0     1
  [32] .rela.debug_range RELA             0000000000000000  08f53f50
       0000000000deb940  0000000000000018   I      38    31     8
  [33] .debug_str        PROGBITS         0000000000000000  09d3f890
       0000000000c841af  0000000000000001  MS       0     0     1
  [34] .comment          PROGBITS         0000000000000000  0a9c3a3f
       0000000000000115  0000000000000001  MS       0     0     1
  [35] .debug_line       PROGBITS         0000000000000000  0a9c3b54
       0000000000375b79  0000000000000000           0     0     1
  [36] .rela.debug_line  RELA             0000000000000000  0ad396d0
       000000000002e9f8  0000000000000018   I      38    35     8
  [37] .rela.init_array  RELA             0000000000000000  0ad680c8
       00000000000003f0  0000000000000018   I      38    18     8
  [38] .symtab           SYMTAB           0000000000000000  0ad684b8
       000000000009f660  0000000000000018          40   22968     8
  [39] .shstrtab         STRTAB           0000000000000000  0ae07b18
       00000000000001d9  0000000000000000           0     0     1
  [40] .strtab           STRTAB           0000000000000000  0ae07cf1
       00000000000b9d8d  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  p (processor specific)

@CcWeapon
Copy link
Author

CcWeapon commented Nov 7, 2022

@maksfb Please help me

@yota9
Copy link
Contributor

yota9 commented Nov 7, 2022

If I correctly understood your problem you should probably update to the latest LLVM-BOLT version: llvm/llvm-project@6b22c37

@CcWeapon
Copy link
Author

CcWeapon commented Nov 8, 2022

If I correctly understood your problem you should probably update to the latest LLVM-BOLT version: llvm/llvm-project@6b22c37

A perfect answer, thank you.

@CcWeapon CcWeapon closed this as completed Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants