[10/18] Link libc.so with libc_nonshared.a to pull in __stack_chk_fail_local.
Commit Message
From: Nick Alcock <nick.alcock@oracle.com>
With this in place, we pull in __stack_chk_fail_local, which will
be required by the next commit, and referenced by every stack-
protected function in libc.
Also prevent that function from being stack-protected itself: this
makes no sense.
v5: Better explanation. Add no-stack-protection of
__stack_chk_fail_local etc.
* Makerules $(common-objpfx)libc.so,
$(common-objpfx)linkobj/libc.so): Add
$(common-objpfx)libc_nonshared.a.
* debug/Makefile (CFLAGS-stack_chk_fail.c): Use $(no-stack-protector).
(CFLAGS-stack_chk_fail_local.c): Likewise.
---
Makerules | 2 ++
debug/Makefile | 6 ++++++
2 files changed, 8 insertions(+)
Comments
Nix <nix@esperi.org.uk> writes:
> @@ -674,6 +674,7 @@ $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty
> # libraries.
> $(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
> $(common-objpfx)libc_pic.os$(libc_pic_clean) \
> + $(common-objpfx)libc_nonshared.a \
Everything needed for libc.so should come from libc_pic.a.
Andreas.
On 8 Mar 2016, Andreas Schwab verbalised:
> Nix <nix@esperi.org.uk> writes:
>
>> @@ -674,6 +674,7 @@ $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty
>> # libraries.
>> $(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
>> $(common-objpfx)libc_pic.os$(libc_pic_clean) \
>> + $(common-objpfx)libc_nonshared.a \
>
> Everything needed for libc.so should come from libc_pic.a.
That means we have to build __stack_check_fail_local into two libraries
at once, since it also has to be in libc_nonshared.a (that's where it is
now and moving it seems likely to be problematic). How does one do that
in the glibc makefile scheme of things?
Nix <nix@esperi.org.uk> writes:
> That means we have to build __stack_check_fail_local into two libraries
> at once, since it also has to be in libc_nonshared.a
libc.so and libc_nonshared.a are variants of the same library.
> How does one do that in the glibc makefile scheme of things?
You can create it under a new name and put it in shared-only-routines.
Andreas.
@@ -674,6 +674,7 @@ $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty
# libraries.
$(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
$(common-objpfx)libc_pic.os$(libc_pic_clean) \
+ $(common-objpfx)libc_nonshared.a \
$(elf-objpfx)sofini.os \
$(elf-objpfx)interp.os \
$(elf-objpfx)ld.so \
@@ -683,6 +684,7 @@ $(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
$(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \
$(common-objpfx)linkobj/libc_pic.a \
+ $(common-objpfx)libc_nonshared.a \
$(elf-objpfx)sofini.os \
$(elf-objpfx)interp.os \
$(elf-objpfx)ld.so \
@@ -52,6 +52,12 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \
$(static-only-routines)
static-only-routines := warning-nop stack_chk_fail_local
+# Building the stack-protector failure routines with stack protection
+# makes no sense.
+
+CFLAGS-stack_chk_fail.c = $(no-stack-protector)
+CFLAGS-stack_chk_fail_local.c = $(no-stack-protector)
+
CFLAGS-backtrace.c = -fno-omit-frame-pointer
CFLAGS-sprintf_chk.c = $(libio-mtsafe)
CFLAGS-snprintf_chk.c = $(libio-mtsafe)