This is an archive of the discontinued LLVM Phabricator instance.

Do not link asan_rtl_x86_64.S for non x86_64 platforms.
ClosedPublic

Authored by CaseySmalley on May 5 2023, 6:48 AM.

Details

Summary

Do not link asan_rtl_x86_64.S for non x86_64 platforms.

Prior to this CL asan_rtl_x86_64.S would be always be linked when
building compiler-rt for non x86_64 platforms, this normally isn't an
issue since at that link time is an empty file anyway.

When attempting to link a Aarch64 program with branch protection enabled
with the address sanitizer.

E.g.

clang --target=aarch64 \
      -fsanitize=address \
      -mbranch-protection=standard \
      -Wl,-z,force-bti
      -o test \
      test.cc

Results in the linking error from the sections generated from the empty
asan_rtl_x86_64.S owed to missing a .note.gnu.property

Also see https://bugs.chromium.org/p/chromium/issues/detail?id=1427165

Diff Detail

Event Timeline

CaseySmalley created this revision.May 5 2023, 6:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2023, 6:48 AM
CaseySmalley requested review of this revision.May 5 2023, 6:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2023, 6:48 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.May 9 2023, 10:59 AM
This revision is now accepted and ready to land.May 9 2023, 10:59 AM
This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.
compiler-rt/lib/asan/CMakeLists.txt
49

On x86-64, if the host compiler supports -m32, default builds will support both i386 and x86_64. This condition will not build asan_rtl_x86_64.S.

I have fixed this in 5717236f7e1fde7948569466fa7dfd7c6562f160