[llvm] [llvm-objcopy] Fix file offsets when PT_INTERP/PT_LOAD offsets are equal (PR #80562)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 11:00:31 PST 2024


MaskRay wrote:

> I'm still verifying this, but it appears that this has injected a crashing bug into Halide HVX codegen, the crash being a misaligned load, at least in the simulator, eg:
> 
> ```
> /home/halidenightly/build_bot/worker/halide-testbranch-main-llvm19-x86-64-linux-cmake/halide-build/test/correctness/correctness_bit_counting
> Hexagon simulator executed function 0x5c4a0 in 1000 cycles
> Hexagon simulator executed function 0x614a0 in 1000 cycles
> Hexagon simulator executed function 0x644c0 in 1000 cycles
> Hexagon simulator executed function 0x88570 in 1000 cycles
> CRASH from thread 0!
> I think the exception was: 0x20, Misaligned Load @ 0x6
> Register Dump (r0 clobbered, pc subject to prior action by the exception handler):
> r00=000000cd r01=00002170 r02=00060b00 r03=00000000
> r04=00000000 r05=00000000 r06=00060ff8 r07=00059b00
> r08=00059b00 r09=00059900 r10=00000000 r11=00000000
> r12=00000000 r13=00000000 r14=00089024 r15=00000000
> r16=00000000 r17=00000000 r18=0005e800 r19=000021e0
> r20=00058008 r21=00063b00 r22=babebeef r23=babebeef
> r24=babebeef r25=babebeef r26=babebeef r27=babebeef
> r28=0004ada0 r29=04159598 r30=041595a0 r31=00012448
> sa0=00088400 lc0=00000001 sa1=00000000 lc1=00000000
> p30=0000ff00  m0=00000000  m1=00000000 usr=00010000
>  pc=00001b3c ugp=00000000  gp=00058000 elr=00022908
> badva0=00000006 badva1=041595f0
> ssr=80140020 ccr=00130000 tid=00000000 imask=00000000
> evb=000000cd modectl=00002170 syscfg=00060b00 ipend=00000000
> ```

The code change is
```
  if (A->Align != B->Align)
    return A->Align > B->Align;
```

and I am quite sure it's correct. Do you have the Halide input to llvm-objcopy? I suspect it incorrectly uses some program headers and relies on the wrong behavior.

https://github.com/llvm/llvm-project/pull/80562


More information about the llvm-commits mailing list