[RFC,4/7] x86/boot/compressed: Adapt sed command if head code is built as PIE

Message ID 0856eaae3439581fdcb7143389ee4cc00859cc9d.1689130310.git.houwenlong.hwl@antgroup.com
State New
Headers
Series [RFC,1/7] x86/head/64: Mark startup_gdt and startup_gdt_descr as __initdata |

Commit Message

Hou Wenlong July 12, 2023, 3:30 a.m. UTC
  When x86/head64_identity.c is built as PIE, all symbols would be set as
hidden to omit GOT references. According to the generic ABI, a hidden
symbol contained in a relocatable object must be either removed or
converted to STB_LOCAL binding by the link-editor when the relocatable
object is included in an executable file or shared object. Both gold and
ld.lld change the binding of a STV_HIDDEND symbol to STB_LOCAL. However,
for GNU ld, it will keep the global hidden. The sed command to generate
voffset.h only captures global symbols, so an empty voffset.h would be
generated with ld.lld. Therefore, local symbols should also be captured
in the sed command.

Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
---
 arch/x86/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 40d2ff503079..ca57ad0d2d22 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -79,7 +79,7 @@  LDFLAGS_vmlinux += -T
 hostprogs	:= mkpiggy
 HOST_EXTRACFLAGS += -I$(srctree)/tools/include
 
-sed-voffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'
+sed-voffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVWabcdgrstvw] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'
 
 quiet_cmd_voffset = VOFFSET $@
       cmd_voffset = $(NM) $< | sed -n $(sed-voffset) > $@