This is an archive of the discontinued LLVM Phabricator instance.

[asan] Changed the label for error reporting code to use GOT instead of PLT.
AbandonedPublic

Authored by kstoimenov on Sep 7 2021, 2:31 PM.

Details

Reviewers
kda
Summary

Switching from PLT to GOT makes following errors go away: "error: 32 bit reloc applied to a field with a different size".

Diff Detail

Unit TestsFailed

Event Timeline

kstoimenov created this revision.Sep 7 2021, 2:31 PM
kstoimenov requested review of this revision.Sep 7 2021, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 7 2021, 2:31 PM
pcc added a subscriber: pcc.Sep 7 2021, 2:40 PM

What's the effect on the relocation types in the object file with this change? I don't think it's valid to have a branch with an @GOT modifier.

What's the effect on the relocation types in the object file with this change? I don't think it's valid to have a branch with an @GOT modifier.

Moving from PTL to GOT fixed this errors like this: "error: 32 bit reloc applied to a field with a different size". What do you thing should be the right type for this? Not specifying PTL also had problems with linking so living in blank is not an option.

kstoimenov edited the summary of this revision. (Show Details)Sep 7 2021, 2:46 PM
pcc added a comment.Sep 7 2021, 2:57 PM

What's the effect on the relocation types in the object file with this change? I don't think it's valid to have a branch with an @GOT modifier.

Moving from PTL to GOT fixed this errors like this: "error: 32 bit reloc applied to a field with a different size". What do you thing should be the right type for this? Not specifying PTL also had problems with linking so living in blank is not an option.

I mean what's the difference in output of objdump -dr file.o before and after.

What's the effect on the relocation types in the object file with this change? I don't think it's valid to have a branch with an @GOT modifier.

Moving from PTL to GOT fixed this errors like this: "error: 32 bit reloc applied to a field with a different size". What do you thing should be the right type for this? Not specifying PTL also had problems with linking so living in blank is not an option.

I mean what's the difference in output of objdump -dr file.o before and after.

Before it was like this:

28:   e9 00 00 00 00          jmpq   2d <__asan_check_store2_rn53+0x2d>
                      29: R_X86_64_PLT32      __asan_report_store2-0x4

With the new flag it is like this:

28:   e9 00 00 00 00          jmpq   2d <__asan_check_store2_rn53+0x2d>
                      29: R_X86_64_GOTPC32    __asan_report_store2-0x4
pcc added a comment.Sep 7 2021, 5:35 PM

Have you verified that things work at runtime with this change? Because I believe that your change will result in branching to the GOT entry for the runtime functions. Since GOT entries are just addresses and are not executable, I believe that this would result in a segfault.

I believe that R_X86_64_PLT32 is the correct relocation to use in this case. What's unclear to me though is how you're getting that error. That should only be happening if the relocation is being applied to an address of the wrong size. Can you check what the value of Type is in checkIs32 in llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp when the check fails? I suspect that the JMP_1 in your instruction somehow remains a JMP_1 instead of being properly "unrelaxed" to JMP_4.

Thanks for the review. I think the culprit was that I was using JMP_1 instead of JMP_4. I will drop this patch and send out another one.

kstoimenov abandoned this revision.Sep 8 2021, 7:42 AM