From c1b57d99779c3ec51217491cddf870658a114ee0 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 26 Nov 2022 16:40:16 +0800 Subject: [PATCH] -r: Do not strip .note.GNU-stack --- elf/input-files.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elf/input-files.cc b/elf/input-files.cc index 43803642..b4ecc14b 100644 --- a/elf/input-files.cc +++ b/elf/input-files.cc @@ -191,7 +191,7 @@ void ObjectFile::initialize_sections(Context &ctx) { // area in GNU linkers. We ignore that section because silently // making the stack area executable is too dangerous. Tell our // users about the difference if that matters. - if (name == ".note.GNU-stack") { + if (name == ".note.GNU-stack" && !ctx.arg.relocatable) { if (shdr.sh_flags & SHF_EXECINSTR) { if (!ctx.arg.z_execstack && !ctx.arg.z_execstack_if_needed) Warn(ctx) << *this << ": this file may cause a segmentation"