arceos-org / percpu

https://arceos-org.github.io/percpu/
1 stars 3 forks source link

[Bug] `SIGSEGV` on newer version of nightly toolchain when running the test #5

Open aarkegz opened 1 month ago

aarkegz commented 1 month ago

A SIGSEGV occurred before main:

aarkegz commented 1 month ago

When compiling with nightly-2024-08-12 on my machine, it fails with test profile but succeeds with dev profile.

Some critical differences have been revealed by readelf:

# in `test`
  [32] .percpu           NOBITS           0000000000000000  000d1000
       0000000000000100  0000000000000000  WA       0     0     8
--------------
# in `dev`
  [31] .percpu           PROGBITS         000000000005e260  0005b260
       0000000000000028  0000000000000000  WA       0     0     8

It was a mistake.

aarkegz commented 3 weeks ago

After switching target to x86_64-unknown-linux-musl, the bug persists but it now won't crash before _start. Debugging and disassembling reveals that it may be a bug that ld -no-pie will uses a dynamic version of crt*.o, and I believe the situation is similar in x86_64-unknown-linux-gnu. Now it's time to consider how to build a PURE static executable, with our custom link script included.