[PATCH] D23674: Do not set __guard_local to hidden for OpenBSD SSP

Stefan Kempf via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 21 07:18:42 PDT 2016


Tim Shen wrote:
> On Fri, Aug 19, 2016 at 10:28 AM Stefan Kempf <sisnkemp at gmail.com> wrote:
> 
> > If M.getOrInsertGlobal() does not return with a GlobalVariable,
> > __guard_local was declared with a different type than long. This
> > is a programming mistake. I decided against the assert here
> > because the linker should catch this, and I wanted to avoid triggering
> > asserts because of programming errors.
> >
> 
> Can you elaborate on "programming mistake"?

__guard_local is a reserved identifier and is supposed to be defined as
long in the startup code or the kernel only. But clang and OpenBSD's gcc
will happily compile a piece of source code that violates this, e.g. by
declaring __guard_local as char, or float (=> "programming mistake").
For such a program, M.getOrInsertGlobal will return a cast operation
instead of a GlobalValue.

My understanding was that asserts are used to check for internal
compiler errors. If something is wrong in the input source code,
normal warnings or errors should be emitted.

Currently the linker stage prevents that an incorrectly redefined
__guard_local is used in the stack protector. Maybe clang could
check this in the future. But I think for the moment we can get away
without additional diagnostics here, and save this for a separate diff.


More information about the llvm-commits mailing list