Commit 1eb2f02
kpatch/LoongArch: Convert PC-relative LA instructions to GOT version for livepatch
Introduces a post-processing function
`kpatch_modify_la_rela_sections()` which:
1. Scans all rela sections within executable segments
(`SHF_EXECINSTR`).
2. Identifies `la` instructions that use the PC-relative sequence
(`pcalau12i + addi.d`) via the `is_la_pcrel()` helper.
3. Modifies the instruction sequence in-place to use the GOT-based
sequence (`pcalau12i + ld.d`) via `la_pcrel_to_la_got()`.
4. Updates the corresponding relocation types from their original
PC-relative types to the appropriate GOT types
(`R_LARCH_GOT_PC_HI20` and `R_LARCH_GOT_PC_LO12`).
Verification:
The modification is confirmed by disassembling the patched code. The
original sequence:
pcalau12i $a1, 40
addi.d $a1, $a1, 56 // PC-relative calculation
Was successfully transformed into the GOT-based sequence:
pcalau12i $a1, 40
ld.d $a1, $a1, 56 // Load from GOT entry
Signed-off-by: george <guodongtai@kylinos.cn>1 parent 2e45b11 commit 1eb2f02
1 file changed
+73
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3520 | 3520 | | |
3521 | 3521 | | |
3522 | 3522 | | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
| 3532 | + | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
| 3539 | + | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
3523 | 3594 | | |
3524 | 3595 | | |
3525 | 3596 | | |
| |||
4374 | 4445 | | |
4375 | 4446 | | |
4376 | 4447 | | |
| 4448 | + | |
| 4449 | + | |
4377 | 4450 | | |
4378 | 4451 | | |
4379 | 4452 | | |
| |||
0 commit comments