Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BaseTools/GenFw: Correct offset when relocating an ADR
In the R_AARCH64_ADR_GOT_PAGE case on AARCH64, we may encounter an ADR instead of an ADRP when the toolchain is working around Cortex-A53 erratum #843419. If that's the case, be sure to calculate the offset appropriately. This resolves an issue experienced when building a StandaloneMm image with stack protection enabled on GCC compiled with "--enable-fix-cortex-a53-843419". This scenario sometimes generates an ADR with a R_AARCH64_ADR_GOT_PAGE relocation. In this scenario, the following code is being generated by the toolchain: # Load to set the stack canary 2ffc: 10028020 adr x0, 8000 <mErrorString+0x1bc> 3008: f940d400 ldr x0, [x0, #424] # Load to check the stack canary 30cc: b0000020 adrp x0, 8000 <mErrorString+0x1bc> 30d0: f940d400 ldr x0, [x0, #424] GenFw rewrote that to: # Load to set the stack canary 2ffc: 10000480 adr x0, 0x308c 3008: 912ec000 add x0, x0, #0xbb0 # Load to check the stack canary 30cc: f0000460 adrp x0, 0x92000 30d0: 912ec000 add x0, x0, #0xbb0 Note that we're now setting the stack canary from the wrong address, resulting in an erroneous stack fault. After this fix, the offset will be calculated correctly for an ADR and the stack canary is set correctly. Signed-off-by: Jake Garver <jake@nvidia.com>
- Loading branch information