[llvm-dev] Using '__attribute__((section("name")))' for inline assembly injection

Martin J. O'Riordan via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 5 01:56:56 PDT 2016


I recently examined a bug in a program, and it turned out that the customer
was using the section attribute as a form of inline-assembly mechanism, with
something like:

 

__attribute__((section("sectionName\nasm\nasm\nasm")))

 

this was really ugly and not at all obvious where the problem originated.
Is there any way of getting LLVM or CLang to validate the name used in the
section attribute?  The GCC definition says that this only permits
alpha-numeric characters, but I know that it is also very common for people
to use '_' and '.' in section names so alpha-numeric checking is probably a
bit over-zealous, but embedded newlines definitely should be considered
suspicious.  Or perhaps there is an existing check in 'clang-tidy'?

 

The reason they were doing this in the first place, is that the 'naked'
attribute does not do what they want, which was to allow them to build
custom prologue and epilogue code for a function.

 

Thanks,

 

            MartinO

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161005/1747ba33/attachment.html>


More information about the llvm-dev mailing list