facebookarchive / BOLT

Binary Optimization and Layout Tool - A linux command-line utility used for optimizing performance of binaries
2.51k stars 176 forks source link

Fix update-debug-sections for AArch64 #255

Closed ElvinaYakubova closed 2 years ago

ElvinaYakubova commented 2 years ago

This patch adds AArch64 relocations handling in case updating of debug sections is enabled.

Refers to https://github.com/facebookincubator/BOLT/pull/253 problem that occurs when update-debug-sections flag is used. Previously, in the updateLineTableOffsets function, only X86 relocation (number 10) was created, and further, that number was passed to the getSizeForType function, which is architecture-dependent, so it tried to find AArch64 relocation with the same number, and it was R_AARCH64_P32_ADR_PREL_LO21.

Elvina Yakubova, Advanced Software Technology Lab, Huawei

maksfb commented 2 years ago

@ElvinaYakubova, thank you for the fix. Could you please add a test case?

ElvinaYakubova commented 2 years ago

@ElvinaYakubova, thank you for the fix. Could you please add a test case?

Sure, will do

ElvinaYakubova commented 2 years ago

Thanks for the review @rafaelauler, fixed as you suggested. I've added tests and also noticed when trying to import line-number.test, that "#debug line" number doesn't always show the correct value, so I'm trying to fix that as well.

rafaelauler commented 2 years ago

Thanks Elvina! Sorry, I tried to import this but the linter is complaining about formatting of the changes in two other files as well (Relocation.cpp, DWARFRewriter.cpp). Could you run clang-format in the changes introduced there too?

ElvinaYakubova commented 2 years ago

@rafaelauler Sorry for the inconvenience, I fixed it, now everything should be ok.

aaupov commented 2 years ago

Committed: 04b81f7fe7dd3fb9dec09f6360ea4f8a1ce4082b.