Issue 119956
Summary Misaligned LOAD segment on llvm-strip output
Labels new issue
Assignees
Reporter tzik
    I hit a misaligned llvm-strip output.
On the second column of the output below should end with 000 to be aligned correctly.
```
-  LOAD           0x00c000 0x000000000000c000 0x000000000000c000 0x001488 0x001489 RW  0x1000
+  LOAD           0x00c002 0x000000000000c000 0x000000000000c000 0x001488 0x001489 RW 0x1000
```

#56738 may be a related issue, but my case didn't use llvm-bolt, and my llvm-strip was new enough to contain [a suggested fix there](https://github.com/llvm/llvm-project/issues/56738#issuecomment-2449258980).
(I'm not sure this is a llvm-strip issue or mold issue, tho.)

Here is a repro case:
```
#!/bin/bash
set -eu

cd "$(dirname "$0")"

if [ ! -e abseil-cpp ]; then
  git clone --depth=1 -b 20240722.0 https://github.com/abseil/abseil-cpp.git
fi

rm -rf build
mkdir -p build
cd build

clang++ --version
ld.mold --version
llvm-strip --version

echo '__attribute__((weak)) void foo() {}' > dummy.cc
clang -fPIC -o dummy.o -c dummy.cc
clang -fuse-ld=mold -shared -o 00.so dummy.o
so_list=({01..22}.so)
for so_file in "${so_list[@]}"; do
  cp 00.so "${so_file}"
done

clang++ -Draw_hash_set_EXPORTS -I../abseil-cpp -DNDEBUG -fPIC -o foo.o -c ../abseil-cpp/absl/container/internal/raw_hash_set.cc
clang++ -fuse-ld=mold -shared -Wl,-soname,foo.so -o foo.so foo.o -Wl,-rpath,'$ORIGIN' "${so_list[@]}"

llvm-readelf -W --segments foo.so | grep LOAD > before_strip
llvm-strip foo.so
llvm-readelf -W --segments foo.so | grep LOAD > after_strip

diff -u0 before_strip after_strip
```

and its output on my env was:
```
clang version 19.1.5 (https://github.com/llvm/llvm-project.git ab4b5a2db582958af1ee308a790cfdb42bd24720)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /home/tzik/work/llvm/out/bin
mold 1.0.3 (compatible with GNU ld)
llvm-strip, compatible with GNU strip
LLVM (http://llvm.org/):
  LLVM version 19.1.5
  Optimized build.
--- before_strip	2024-12-14 14:48:09.957991233 +0900
+++ after_strip	2024-12-14 14:48:09.967991256 +0900
@@ -3 +3 @@
-  LOAD           0x00c000 0x000000000000c000 0x000000000000c000 0x001488 0x001489 RW  0x1000
+  LOAD           0x00c002 0x000000000000c000 0x000000000000c000 0x001488 0x001489 RW  0x1000
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to