The original computation for shared object symbol alignment is wrong when st_value equals 0.
It is very unusual for dso symbols to have st_value equal 0. But when it happens, it causes obscure run time bugs.
Differential D47602
Correct aligment computation for shared object symbols shenhan on May 31 2018, 12:31 PM. Authored by
Details The original computation for shared object symbol alignment is wrong when st_value equals 0. It is very unusual for dso symbols to have st_value equal 0. But when it happens, it causes obscure run time bugs.
Diff Detail Event TimelineComment Actions Thanks Rui. I just updated the patch a little bit, that - st_value is only valid for alignment when symbol shndx is set to SHN_COMMON. I'll add a test case and fix other failing tests. Thanks.
Comment Actions Common symbol is for (linkable) object files. Linked object files (i.e. execuables or DSOs) don't contain common symbols.
Comment Actions
Comment Actions Sounds good. Even in the case where the virtual address is intentionally 0, we would still want to use the sh_addralign alignment.
Comment Actions @pcc thanks for the review. Updated the patch -
Comment Actions Re-write the getAlignment function, keep the original logic but with the 3 additional tests:
Comment Actions LGTM
|
Is that correct? If there is a symbol at virtual address 0 in an unknown section, doesn't that mean that we should error out via the Ret > UINT32_MAX code path below since we don't know what alignment to use?