I think $subject needs a typo update... vdso32... On Tue, Sep 01, 2020 at 03:25:23PM -0700, Nick Desaulniers wrote: > Rather than invoke the compiler as the driver, use the linker. That way > we can check --orphan-handling=warn support correctly, as cc-ldoption > was removed in > commit 055efab3120b ("kbuild: drop support for cc-ldoption"). > > Requires dropping the .got section. I couldn't find how it was used in > the vdso32. > > Fixes: commit f2af201002a8 ("powerpc/build: vdso linker warning for orphan > sections") > Link: > https://lore.kernel.org/lkml/cakwvodnn3wxydjomvnveyd_njwrku3fabwt_bs92duihhyw...@mail.gmail.com/ > Signed-off-by: Nick Desaulniers <ndesaulni...@google.com> > --- > Not sure removing .got is a good idea or not. Otherwise I observe the > following link error: > powerpc-linux-gnu-ld: warning: orphan section `.got' from > `arch/powerpc/kernel/vdso32/sigtramp.o' being placed in section `.got' > powerpc-linux-gnu-ld: _GLOBAL_OFFSET_TABLE_ not defined in linker created .got > powerpc-linux-gnu-ld: final link failed: bad value
If it's like the x86 and arm toolchains, I think you'll be required to keep .got, but you can assert it to a 0 size, e.g.: /* * Sections that should stay zero sized, which is safer to * explicitly check instead of blindly discarding. */ .got : { *(.got) } ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") (and put that at the end of the linker script) -Kees > > sigtramp.c doesn't mention anything from the GOT AFAICT, and doesn't > look like it contains relocations that do, so I'm not sure where > references to _GLOBAL_OFFSET_TABLE_ are coming from. > > arch/powerpc/kernel/vdso32/Makefile | 7 +++++-- > arch/powerpc/kernel/vdso32/vdso32.lds.S | 3 ++- > 2 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/kernel/vdso32/Makefile > b/arch/powerpc/kernel/vdso32/Makefile > index 87ab1152d5ce..611a5951945a 100644 > --- a/arch/powerpc/kernel/vdso32/Makefile > +++ b/arch/powerpc/kernel/vdso32/Makefile > @@ -27,6 +27,9 @@ UBSAN_SANITIZE := n > ccflags-y := -shared -fno-common -fno-builtin -nostdlib \ > -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both > asflags-y := -D__VDSO32__ -s > +ldflags-y := -shared -soname linux-vdso32.so.1 \ > + $(call ld-option, --eh-frame-hdr) \ > + $(call ld-option, --orphan-handling=warn) -T > > obj-y += vdso32_wrapper.o > extra-y += vdso32.lds > @@ -49,8 +52,8 @@ $(obj-vdso32): %.o: %.S FORCE > $(call if_changed_dep,vdso32as) > > # actual build commands > -quiet_cmd_vdso32ld = VDSO32L $@ > - cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ $(call > cc-ldoption, -Wl$(comma)--orphan-handling=warn) -Wl,-T$(filter %.lds,$^) > $(filter %.o,$^) > +quiet_cmd_vdso32ld = LD $@ > + cmd_vdso32ld = $(cmd_ld) > quiet_cmd_vdso32as = VDSO32A $@ > cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $< > > diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S > b/arch/powerpc/kernel/vdso32/vdso32.lds.S > index 4c985467a668..0ccdebad18b8 100644 > --- a/arch/powerpc/kernel/vdso32/vdso32.lds.S > +++ b/arch/powerpc/kernel/vdso32/vdso32.lds.S > @@ -61,7 +61,6 @@ SECTIONS > .fixup : { *(.fixup) } > > .dynamic : { *(.dynamic) } :text :dynamic > - .got : { *(.got) } :text > .plt : { *(.plt) } > > _end = .; > @@ -108,7 +107,9 @@ SECTIONS > .debug_varnames 0 : { *(.debug_varnames) } > > /DISCARD/ : { > + *(.got) > *(.note.GNU-stack) > + *(.branch_lt) > *(.data .data.* .gnu.linkonce.d.* .sdata*) > *(.bss .sbss .dynbss .dynsbss) > *(.glink .iplt .plt .rela*) > -- > 2.28.0.402.g5ffc5be6b7-goog > -- Kees Cook