Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 775140

Summary: sys-libs/glibc-2.32-r7 does not respect LDFLAG norelro
Product: Gentoo Linux Reporter: Agostino Sarubbo <ago>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED INVALID    
Severity: normal CC: esigra
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 331933    

Description Agostino Sarubbo gentoo-dev 2021-03-09 21:30:57 UTC
If you compile the package with:
LDFLAGS=" -Wl,--hash-style=gnu -Wl,-z,norelro"
you won't see "No Relro" so it is not respected

To test please use checksec from app-admin/checksec
 ~ $ checksec --file=/lib64/libc-2.32.so
RELRO           STACK CANARY      NX            PIE             RPATH      RUNPATH	Symbols		FORTIFY	Fortified	Fortifiable	FILE
Full RELRO      Canary found      NX enabled    DSO             No RPATH   No RUNPATH   No Symbols	  Yes	79		170		/lib64/libc-2.32.so
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2021-03-10 08:18:16 UTC
glibc explicitly overrides relro value:

Makeconfig-+link-before-libc = -nostdlib -nostartfiles -o $@ \
Makeconfig-           $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
Makeconfig:           $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
Makeconfig-           $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
Makeconfig-           $(+preinit) $(+prector) \
Makeconfig-           $(filter-out $(addprefix $(csu-objpfx),start.o \
Makeconfig-                                                  $(start-installed-name))\
Makeconfig-                        $(+preinit) $(link-extra-libs) \
Makeconfig-                        $(common-objpfx)libc% $(+postinit),$^) \
Makeconfig-           $(link-extra-libs)

What behaviour do you expect?
Comment 2 Agostino Sarubbo gentoo-dev 2021-03-10 08:53:22 UTC
(In reply to Sergei Trofimovich from comment #1)
> glibc explicitly overrides relro value:
> 
> Makeconfig-+link-before-libc = -nostdlib -nostartfiles -o $@ \
> Makeconfig-           $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
> Makeconfig:           $(combreloc-LDFLAGS) $(relro-LDFLAGS)
> $(hashstyle-LDFLAGS) \
> Makeconfig-           $(firstword $(CRT-$(@F))
> $(csu-objpfx)$(start-installed-name)) \
> Makeconfig-           $(+preinit) $(+prector) \
> Makeconfig-           $(filter-out $(addprefix $(csu-objpfx),start.o \
> Makeconfig-                                                 
> $(start-installed-name))\
> Makeconfig-                        $(+preinit) $(link-extra-libs) \
> Makeconfig-                        $(common-objpfx)libc% $(+postinit),$^) \
> Makeconfig-           $(link-extra-libs)
> 
> What behaviour do you expect?

I'd expect user flags always override default flags unless it is well known to break.
Comment 3 SpanKY gentoo-dev 2021-03-13 16:23:53 UTC
(In reply to Agostino Sarubbo from comment #2)

it is going to break.  glibc clobbers flags when it must.  it's producing the fundamental libs in your system used to bootstrap all other processes.
Comment 4 Andreas K. Hüttel archtester gentoo-dev 2021-07-01 21:27:26 UTC
(In reply to SpanKY from comment #3)
> (In reply to Agostino Sarubbo from comment #2)
> 
> it is going to break.  glibc clobbers flags when it must.  it's producing
> the fundamental libs in your system used to bootstrap all other processes.