Skip to contentSkip to conversation

x86/darwin: two extra fixes to placate build warnings

PATCH In review Roger Pau Monne 2 participants 4 messages Feb 13

lore
Share & tools
lore
#0 lore raw

cover x86/darwin: two extra fixes to placate build warnings

Hello,

Following two patches fix the remaining two warnings seen on the x86 Darwin build of Xen.

Thanks, Roger.

Roger Pau Monne (2):
xen/x86: fix usage of [[:blank:]] with BSD grep
xen: add non-executable stack note uniformly

 xen/Makefile         | 2 +-
 xen/arch/x86/arch.mk | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/2 xen/x86: fix usage of [[:blank:]] with BSD grep

BSD grep only recognizes [[:blank:]] as a valid expression when using extended (modern) regular expressions. Pass -E to the grep call used in efi-nr-fixups.

Additionally, the return from wc -l is space padded on BSD, and hence
the content of efi-nr-fixups is " 2", not plain "2". Strip the
spaces in the Makefile using $(strip ...).

Fixes 1be65ec4c8bc ('x86/EFI: avoid use of GNU ld's --disable-reloc-section when possible')
---
 xen/arch/x86/arch.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/arch.mk +1 -1
index 2e06ae2582dc..37fe65bc13cb 100644
@@ -100,7 +100,7 @@ endif
 ifeq ($(XEN_BUILD_PE),y)
 
 # Check if the linker produces fixups in PE by default
-efi-nr-fixups := $(shell LC_ALL=C $(OBJDUMP) -p $(efi-check).efi | grep '^[[:blank:]]*reloc[[:blank:]]*[0-9][[:blank:]].*DIR64$$' | wc -l)
+efi-nr-fixups := $(strip $(shell LC_ALL=C $(OBJDUMP) -p $(efi-check).efi | grep -E '^[[:blank:]]*reloc[[:blank:]]*[0-9][[:blank:]].*DIR64$$' | wc -l))
 
 ifeq ($(efi-nr-fixups),2)
 MKRELOC := :
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/2 xen: add non-executable stack note uniformly

In reply to Roger Pau Monne

Currently the -Wa,--noexecstack parameter is only passed to the compiler when building assembly files, as the assembler doesn't add such note for stack attributes.

However, the default addition of the .note.GNU-stack section is dependent on the ELF target used. Adjust the passing of -Wa,--noexecstack so it's added to CFLAGS instead of AFLAGS, and hence such section is also added to object files generated from .c sources. This fixes the complains from the linker about missing .note.GNU-stack section when building x86-64 Xen on Darwin platforms.

Note we could instead pass -z noexecstack to the linker, but that however would mask any possible errors or unintended mismatches from previous steps.

---
 xen/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/Makefile +1 -1
index a054315fa4a2..a2b442e76d5c 100644
@@ -413,7 +413,7 @@ ifneq ($(CONFIG_CC_IS_CLANG),y)
 CFLAGS += -Wa,--strip-local-absolute
 endif
 
-$(call cc-option-add,AFLAGS,CC,-Wa$$(comma)--noexecstack)
+$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--noexecstack)
 
 LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
 
Signature · 1 line
2.51.0
Acked-by on the v1 series
#3 lore raw
In reply to Roger Pau Monne
Quoted 10 lines · Roger Pau Monne

Hello,

Following two patches fix the remaining two warnings seen on the x86 Darwin build of Xen.

Thanks, Roger.

Roger Pau Monne (2):
xen/x86: fix usage of [[:blank:]] with BSD grep
xen: add non-executable stack note uniformly