[Letux-kernel] [PATCH 1/2] x86/tools/relocs: Fix non-POSIX regexp

Andreas Kemnade andreas at kemnade.info
Sat Jul 3 17:58:27 CEST 2021


Hi,

On Sat,  3 Jul 2021 15:48:37 +0200
"H. Nikolaus Schaller" <hns at goldelico.com> wrote:

> Trying to run the x86 relocs tool on a BSD based HOSTCC leads
> to errors like
> 
>   VOFFSET arch/x86/boot/compressed/../voffset.h - due to: vmlinux
>   CC      arch/x86/boot/compressed/misc.o - due to: arch/x86/boot/compressed/../voffset.h
>   OBJCOPY arch/x86/boot/compressed/vmlinux.bin - due to: vmlinux
>   RELOCS  arch/x86/boot/compressed/vmlinux.relocs - due to: vmlinux
> empty (sub)expressionarch/x86/boot/compressed/Makefile:118: recipe for target 'arch/x86/boot/compressed/vmlinux.relocs' failed
> make[3]: *** [arch/x86/boot/compressed/vmlinux.relocs] Error 1
> 
> and when cross-cpmpiling for MIPS
> 
>   SYNC    include/config/auto.conf.cmd - due to: .config
> egrep: empty (sub)expression
>   UPD     include/config/kernel.release
>   HOSTCC  scripts/dtc/dtc.o - due to target missing
> 
> It turns out that relocs.c and egrep use patterns like
> 
> 	"something(|_end)"
> 
> This is not valid syntax according to POSIX 9.5.3 ERE Grammar
> 
> 	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
> 
> but seems to be silently accepted by the Linux regcmp() implementation
> while a BSD host complains.
> 
and feels valid by common sense but not by the standard...

> They can be replaced by a transformation like
> 
> 	"(|p1|p2)" -> "(p1|p2)?"
> 
this all make sense,
Fixes: fd952815307f ("x86-32, relocs: Whitelist more symbols for ld bug
workaround")


> Signed-off-by: H. Nikolaus Schaller <hns at goldelico.com>
> ---
>  arch/x86/tools/relocs.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
> index 04c5a44b96827..9ba700dc47de4 100644
> --- a/arch/x86/tools/relocs.c
> +++ b/arch/x86/tools/relocs.c
> @@ -57,12 +57,12 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
>  	[S_REL] =
>  	"^(__init_(begin|end)|"
>  	"__x86_cpu_dev_(start|end)|"
> -	"(__parainstructions|__alt_instructions)(|_end)|"
> -	"(__iommu_table|__apicdrivers|__smp_locks)(|_end)|"
> +	"(__parainstructions|__alt_instructions)(_end)?|"
> +	"(__iommu_table|__apicdrivers|__smp_locks)(_end)?|"
>  	"__(start|end)_pci_.*|"
>  	"__(start|end)_builtin_fw|"
> -	"__(start|stop)___ksymtab(|_gpl)|"
> -	"__(start|stop)___kcrctab(|_gpl)|"
> +	"__(start|stop)___ksymtab(_gpl)?|"
> +	"__(start|stop)___kcrctab(_gpl)?|"
>  	"__(start|stop)___param|"
>  	"__(start|stop)___modver|"
>  	"__(start|stop)___bug_table|"



More information about the Letux-kernel mailing list