This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Avoid crashing on invalid -Wa,-march= values
ClosedPublic

Authored by dim on Nov 28 2021, 10:13 AM.

Details

Summary

As reported in https://bugs.freebsd.org/260078, the gnutls Makefiles
pass -Wa,-march=all to compile a number of assembly files. Clang does
not support this -march value, but because of a mistake in handling
the arguments, an unitialized Arg pointer is dereferenced, which can
cause a segfault.

Work around this by adding a check if the local WaMArch variable is
initialized, and if so, using its value in the diagnostic message.

Diff Detail

Event Timeline

dim created this revision.Nov 28 2021, 10:13 AM
dim requested review of this revision.Nov 28 2021, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2021, 10:13 AM
tschuett added inline comments.
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
263

Would an if statement be more readable and actually show what the issue is?

Bonus points for a comment.

There is precedence for checking WaMArch.size() in the file. I would expected !WaMArch.empty().

dim updated this revision to Diff 390218.Nov 28 2021, 10:39 AM

Address review comments.

This revision is now accepted and ready to land.Nov 28 2021, 12:02 PM
This revision was landed with ongoing or failed builds.Nov 28 2021, 1:24 PM
This revision was automatically updated to reflect the committed changes.