Skip to contentSkip to conversation

Fix the ld flags not be applied to tst-execstack-mod.so

PATCH New Vineet Gupta 3 participants 6 messages Jul 25, 2018 – Jul 26, 2018 1 message not in the archive Synopsys ARC architecture

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Fix the ld flags not be applied to tst-execstack-mod.so

Quoted 3 lines · Zong Li

The Makefile variable name loses the file extension (.so). It causes the linker option not applies to the corresponding file that it's file name matchs with the variable without LDFLAGS- prefix.

Hi,

Chiming in as I'm looking into these things myself in context of testing for ARC port submission. Do we really need to fix this part - in this way. I'd vote to not force the execstack through linker and rely on gcc generating this itself when it knows it doing something for trampolines. And only if target gcc doesn't support it (detected via configure test) should this be done.

-Vineet

Quoted 35 lines

* elf/Makefile (LDFLAGS-tst-execstack-mod): Change variable name by adding the file extension (.so).

---
 ChangeLog    | 5 +++++
 elf/Makefile | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
ChangeLog +5 -0
index b45c83b..f87b32c 100644
@@ -1,3 +1,8 @@
+2018-07-20  Zong Li  <zong at andestech.com>
+
+	* elf/Makefile (LDFLAGS-tst-execstack-mod): Change variable name by
+	adding the file extension (.so).
+
 2018-07-20  Samuel Thibault  <samuel.thibault at ens-lyon.org>
 
 	* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Set multiple_threads
elf/Makefile +1 -1
index cd07713..ecc8ea2 100644
@@ -1004,7 +1004,7 @@ $(objpfx)tst-execstack: $(libdl)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
-LDFLAGS-tst-execstack-mod = -Wl,-z,execstack
+LDFLAGS-tst-execstack-mod.so = -Wl,-z,execstack
 
 $(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so
 LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack
#2 lore raw

PATCH 1/1 Fix the ld flags not be applied to tst-execstack-mod.so

Quoted 6 lines · Vineet Gupta

Chiming in as I'm looking into these things myself in context of testing for ARC port submission. Do we really need to fix this part - in this way. I'd vote to not force the execstack through linker and rely on gcc generating this itself when it knows it doing something for trampolines. And only if target gcc doesn't support it (detected via configure test) should this be done.

The whole point of this test is to verify executable stack changes on dlopen of a module requiring an executable stack. Thus, for this test to work correctly, this module must be forced to have a marking as needing an executable stack.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#3 lore raw

PATCH 1/1 Fix the ld flags not be applied to tst-execstack-mod.so

Quoted 10 lines · Joseph Myers
Quoted 6 lines · Vineet Gupta

Chiming in as I'm looking into these things myself in context of testing for ARC port submission. Do we really need to fix this part - in this way. I'd vote to not force the execstack through linker and rely on gcc generating this itself when it knows it doing something for trampolines. And only if target gcc doesn't support it (detected via configure test) should this be done.

The whole point of this test is to verify executable stack changes on dlopen of a module requiring an executable stack.

I'm not contesting that at all. For this exact test, I recently had to fix a kernel bug for allowing mprotect(PROT_EXEC) stack mappings on ARC.

Quoted 3 lines

Thus, for this test to
work correctly, this module must be forced to have a marking as needing an executable stack.

But given the dso code has nested function, a well equipped gcc when generating trampoline code would also generate the GNU_STACK segment for the dso automatically, without need to force the same via the linker flags as is done in the Makefile currently. Only when a port's gcc doesn't support this (ARC gcc didn't until recently), should we need ld assist, and this could be detected using a configure test - No ?

#4 lore raw

PATCH 1/1 Fix the ld flags not be applied to tst-execstack-mod.so

Quoted 6 lines · Vineet Gupta

But given the dso code has nested function, a well equipped gcc when generating trampoline code would also generate the GNU_STACK segment for the dso automatically, without need to force the same via the linker flags as is done in the Makefile currently. Only when a port's gcc doesn't support this (ARC gcc didn't until recently), should we need ld assist, and this could be detected using a configure test - No ?

The test should achieve the executable stack markings independent of whether nested functions require them on that architecture (for example, it should still have the markings on architectures with function descriptors).

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com
#5 lore raw

PATCH 1/1 Fix the ld flags not be applied to tst-execstack-mod.so

Joseph Myers <joseph at codesourcery.com> ? 2018?7?26? ?? ??4:56???

Quoted 10 lines · Vineet Gupta
Quoted 7 lines

But given the dso code has nested function, a well equipped gcc when generating trampoline code would also generate the GNU_STACK segment for the dso automatically, without need to force the same via the linker flags as is done in the Makefile currently. Only when a port's gcc doesn't support this (ARC gcc didn't until recently), should we need ld assist, and this could be detected using a configure test - No ?

Quoted 5 lines

The test should achieve the executable stack markings independent of whether nested functions require them on that architecture (for example, it should still have the markings on architectures with function descriptors).

In glibc now, this option doesn't pass to linker, the module is still not executable on stack.
I think that we need this patch to fix up it or another patch to remove the variable in Makefile
if it is not necessary. Both are fine for me. For now, it is a little bit strange because it present
in Makefile but has no effect.

#6 lore raw

PATCH 1/1 Fix the ld flags not be applied to tst-execstack-mod.so

Quoted 5 lines · Zong Li

In glibc now, this option doesn't pass to linker, the module is still not executable on stack. I think that we need this patch to fix up it or another patch to remove the variable in Makefile if it is not necessary. Both are fine for me. For now, it is a little bit strange because it present in Makefile but has no effect.

I think we should have the option in a properly named variable. But the patch will need review and we're currently in a release freeze.

Signature · 2 lines
Joseph S. Myers
joseph at codesourcery.com