[PATCH] D137384: [MC][LoongArch] Fix needsRelocateWithSymbol() implementation

Youling Tang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 20:15:16 PDT 2022


tangyouling added a comment.

This patch fixes some of the CallTrace issues like the following:

Before applying the patch.

  $ ./test/asan/LOONGARCH64LinuxConfig/TestCases/Posix/Output/shared-lib-test.cpp.tmp
  opening ./test/asan/LOONGARCH64LinuxConfig/TestCases/Posix/Output/shared-lib-test.cpp.tmp-so.so ... 
  ok
  =================================================================
  ==621522==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7ffff150c1bc at pc 0x7ffff1504cd8 bp 0x7ffffb8e7770 sp 0x7ffffb8e7758
  READ of size 4 at 0x7ffff150c1bc thread T0
      #0 0x7ffff1504cd4 in inc /home/loongson/llvm-work/llvm-project-test2/llvm-project/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cpp:49:14
      #1 0x555555db014c  (/home/loongson/llvm-work/llvm-project-test2/llvm-project/build_crt/test/asan/LOONGARCH64LinuxConfig/TestCases/Posix/Output/shared-lib-test.cpp.tmp+0x10c14c)
      #2 0x7ffff1921678  (/usr/lib64/libc.so.6+0x25678)
      #3 0x7ffff1921764 in __libc_start_main (/usr/lib64/libc.so.6+0x25764)
      #4 0x555555ccafc4 in _start /opt/mylaos/build/glibc-2.36/csu/../sysdeps/loongarch/start.S:61

After applying the patch.

  $ ./test/asan/LOONGARCH64LinuxConfig/TestCases/Posix/Output/shared-lib-test.cpp.tmp
  opening ./test/asan/LOONGARCH64LinuxConfig/TestCases/Posix/Output/shared-lib-test.cpp.tmp-so.so ... 
  ok
  =================================================================
  ==586862==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7ffff258c1bc at pc 0x7ffff2584cd8 bp 0x7ffffba7bfb0 sp 0x7ffffba7bf98
  READ of size 4 at 0x7ffff258c1bc thread T0
      #0 0x7ffff2584cd4 in inc /home/loongson/llvm-work/llvm-project-test2/llvm-project/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cpp:49:14
      #1 0x555558838150 in main /home/loongson/llvm-work/llvm-project-test2/llvm-project/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cpp:33:3
      #2 0x7ffff29a1678  (/usr/lib64/libc.so.6+0x25678)
      #3 0x7ffff29a1764 in __libc_start_main (/usr/lib64/libc.so.6+0x25764)
      #4 0x555558752fc4 in _start /opt/mylaos/build/glibc-2.36/csu/../sysdeps/loongarch/start.S:61

We can see that `#1` can find the location of the file where the function is located.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137384/new/

https://reviews.llvm.org/D137384



More information about the llvm-commits mailing list