Skip to contentSkip to conversation

Regex fixes for mips and x86 cross-compile

PATCH In review H. Nikolaus Schaller 3 participants 9 messages Jul 8, 2021 – Aug 5, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Regex fixes for mips and x86 cross-compile

Trying to run the x86 relocs tool on a BSD based HOSTCC (cross compilation environment) 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 compiling a MIPS kernel on a BSD based HOSTCC we get errors like

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 on x86 uses patterns like

	"something(|_end)"

while MIPS uses egrep with

	(|MINOR_|PATCHLEVEL_)

In both cases it is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux regcmp() or egrep implementation while a BSD host complains.

Such patterns can be replaced by a transformation like

	"(|p1|p2)" -> "(p1|p2)?"

Test Linux:

root@letux:~# echo foo | egrep '^(|foo)$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(|foo)$'
root@letux:~# echo f | egrep '^(|foo)$'
root@letux:~# echo | egrep '^(|foo)$'
root@letux:~# echo foo | egrep '^(foo)?$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(foo)?$'
root@letux:~# echo f | egrep '^(foo)?$'
root@letux:~# echo | egrep '^(foo)?$'

root@letux:~#

Test BSD:

iMac:master hns$ echo foo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo fool | egrep '^(foo)?$'
egrep: empty (sub)expression
iMac:master hns$ echo fun | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo f | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo foo | egrep '^(foo)?$'
foo
iMac:master hns$ echo fool | egrep '^(foo)?$'
iMac:master hns$ echo fun | egrep '^(foo)?$'
iMac:master hns$ echo f | egrep '^(foo)?$'
iMac:master hns$ echo | egrep '^(foo)?$'

iMac:master hns$

H. Nikolaus Schaller (2):
x86/tools/relocs: Fix non-POSIX regexp
arch: mips: Fix non-POSIX regexp

 arch/mips/Makefile      | 2 +-
 arch/x86/tools/relocs.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/2 x86/tools/relocs: Fix non-POSIX regexp

Trying to run a cross-compiled 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

It turns out that relocs.c uses patterns like

	"something(|_end)"

This is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux regexp() implementation while a BSD host complains.

Such patterns can be replaced by a transformation like

	"(|p1|p2)" -> "(p1|p2)?"
Fixes fd952815307f ("x86-32, relocs: Whitelist more symbols for ld bug workaround")
---
 arch/x86/tools/relocs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/tools/relocs.c +4 -4
index 04c5a44b96827..9ba700dc47de4 100644
@@ -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|"
Signature · 1 line
2.31.1
#2 lore raw

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

Quoted 23 lines · H. Nikolaus Schaller

Trying to run a cross-compiled 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

It turns out that relocs.c uses patterns like

        "something(|_end)"

This is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

        https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux regexp() implementation while a BSD host complains.

Quoted 7 lines

Such patterns can be replaced by a transformation like

        "(|p1|p2)" -> "(p1|p2)?"
Fixes fd952815307f ("x86-32, relocs: Whitelist more symbols for ld bug workaround")

---

Applied to linux-kbuild/fixes.
Thanks.

Quoted 27 lines
 arch/x86/tools/relocs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/tools/relocs.c +4 -5
index 04c5a44b96827..9ba700dc47de4 100644
@@ -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|"
--

2.31.1

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

PATCH 2/2 arch: mips: Fix non-POSIX regexp

In reply to H. Nikolaus Schaller

When cross compiling a MIPS kernel on a BSD based HOSTCC leads to errors like

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 egrep uses this egrep pattern:

		(|MINOR_|PATCHLEVEL_)

This is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux egrep implementation while a BSD host complains.

Such patterns can be replaced by a transformation like

	"(|p1|p2)" -> "(p1|p2)?"
Fixes 48c35b2d245f ("[MIPS] There is no __GNUC_MAJOR__")
---
 arch/mips/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Makefile +1 -1
index 258234c35a096..674f68d16a73f 100644
@@ -321,7 +321,7 @@ KBUILD_LDFLAGS		+= -m $(ld-emul)
 
 ifdef CONFIG_MIPS
 CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
-	egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \
+	egrep -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \
 	sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
 endif
 
Signature · 1 line
2.31.1
#4 lore raw

Re: [PATCH 2/2] arch: mips: Fix non-POSIX regexp

Quoted 21 lines · H. Nikolaus Schaller

When cross compiling a MIPS kernel on a BSD based HOSTCC leads to errors like

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 egrep uses this egrep pattern:

                (|MINOR_|PATCHLEVEL_)

This is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

        https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux egrep implementation while a BSD host complains.

Quoted 7 lines

Such patterns can be replaced by a transformation like

        "(|p1|p2)" -> "(p1|p2)?"
Fixes 48c35b2d245f ("[MIPS] There is no __GNUC_MAJOR__")

---

Applied to linux-kbuild/fixes.
Thanks.

Quoted 19 lines
 arch/mips/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Makefile +1 -2
index 258234c35a096..674f68d16a73f 100644
@@ -321,7 +321,7 @@ KBUILD_LDFLAGS              += -m $(ld-emul)
 
 ifdef CONFIG_MIPS
 CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
-       egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \
+       egrep -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \
        sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
 endif
 
--

2.31.1

Signature · 2 lines
Best Regards
Masahiro Yamada
#5 lore raw
In reply to H. Nikolaus Schaller

Any chance that it gets merged?

Quoted 91 lines

Am 08.07.2021 um 10:57 schrieb H. Nikolaus Schaller <[email protected]>:

Trying to run the x86 relocs tool on a BSD based HOSTCC (cross compilation environment) 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 compiling a MIPS kernel on a BSD based HOSTCC we get errors like

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 on x86 uses patterns like

	"something(|_end)"

while MIPS uses egrep with

	(|MINOR_|PATCHLEVEL_)

In both cases it is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux regcmp() or egrep implementation while a BSD host complains.

Such patterns can be replaced by a transformation like

	"(|p1|p2)" -> "(p1|p2)?"

Test Linux:

root@letux:~# echo foo | egrep '^(|foo)$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(|foo)$'
root@letux:~# echo f | egrep '^(|foo)$'
root@letux:~# echo | egrep '^(|foo)$'
root@letux:~# echo foo | egrep '^(foo)?$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(foo)?$'
root@letux:~# echo f | egrep '^(foo)?$'
root@letux:~# echo | egrep '^(foo)?$'

root@letux:~#

Test BSD:

iMac:master hns$ echo foo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo fool | egrep '^(foo)?$'
egrep: empty (sub)expression
iMac:master hns$ echo fun | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo f | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo foo | egrep '^(foo)?$'
foo
iMac:master hns$ echo fool | egrep '^(foo)?$'
iMac:master hns$ echo fun | egrep '^(foo)?$'
iMac:master hns$ echo f | egrep '^(foo)?$'
iMac:master hns$ echo | egrep '^(foo)?$'

iMac:master hns$

H. Nikolaus Schaller (2):
x86/tools/relocs: Fix non-POSIX regexp
arch: mips: Fix non-POSIX regexp

arch/mips/Makefile | 2 +-
arch/x86/tools/relocs.c | 8 ++++----

2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1
#6 lore raw

+ Masahiro, linux-kbuild (EOM)

Quoted 95 lines · H. Nikolaus Schaller

Any chance that it gets merged?

Quoted 91 lines

Am 08.07.2021 um 10:57 schrieb H. Nikolaus Schaller <[email protected]>:

Trying to run the x86 relocs tool on a BSD based HOSTCC (cross compilation environment) 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 compiling a MIPS kernel on a BSD based HOSTCC we get errors like

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 on x86 uses patterns like

      "something(|_end)"

while MIPS uses egrep with

      (|MINOR_|PATCHLEVEL_)

In both cases it is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

      https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux regcmp() or egrep implementation while a BSD host complains.

Such patterns can be replaced by a transformation like

      "(|p1|p2)" -> "(p1|p2)?"

Test Linux:

root@letux:~# echo foo | egrep '^(|foo)$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(|foo)$'
root@letux:~# echo f | egrep '^(|foo)$'
root@letux:~# echo | egrep '^(|foo)$'
root@letux:~# echo foo | egrep '^(foo)?$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(foo)?$'
root@letux:~# echo f | egrep '^(foo)?$'
root@letux:~# echo | egrep '^(foo)?$'

root@letux:~#

Test BSD:

iMac:master hns$ echo foo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo fool | egrep '^(foo)?$'
egrep: empty (sub)expression
iMac:master hns$ echo fun | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo f | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo foo | egrep '^(foo)?$'
foo
iMac:master hns$ echo fool | egrep '^(foo)?$'
iMac:master hns$ echo fun | egrep '^(foo)?$'
iMac:master hns$ echo f | egrep '^(foo)?$'
iMac:master hns$ echo | egrep '^(foo)?$'

iMac:master hns$

H. Nikolaus Schaller (2):
x86/tools/relocs: Fix non-POSIX regexp
arch: mips: Fix non-POSIX regexp

arch/mips/Makefile | 2 +-
arch/x86/tools/relocs.c | 8 ++++----

2 files changed, 5 insertions(+), 5 deletions(-)

--
2.31.1

Signature · 2 lines
Thanks,
~Nick Desaulniers
#7 lore raw

Hi all,
any chance to get that reviewed and merged into v5.15-rc1 and backported to stable? Thank you,
Nikolaus Schaller

Quoted 105 lines

Am 19.07.2021 um 22:37 schrieb Nick Desaulniers <[email protected]>:

+ Masahiro, linux-kbuild (EOM)

Quoted 95 lines · H. Nikolaus Schaller

Any chance that it gets merged?

Quoted 91 lines

Am 08.07.2021 um 10:57 schrieb H. Nikolaus Schaller <[email protected]>:

Trying to run the x86 relocs tool on a BSD based HOSTCC (cross compilation environment) 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 compiling a MIPS kernel on a BSD based HOSTCC we get errors like

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 on x86 uses patterns like

     "something(|_end)"

while MIPS uses egrep with

     (|MINOR_|PATCHLEVEL_)

In both cases it is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

     https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux regcmp() or egrep implementation while a BSD host complains.

Such patterns can be replaced by a transformation like

     "(|p1|p2)" -> "(p1|p2)?"

Test Linux:

root@letux:~# echo foo | egrep '^(|foo)$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(|foo)$'
root@letux:~# echo f | egrep '^(|foo)$'
root@letux:~# echo | egrep '^(|foo)$'
root@letux:~# echo foo | egrep '^(foo)?$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(foo)?$'
root@letux:~# echo f | egrep '^(foo)?$'
root@letux:~# echo | egrep '^(foo)?$'

root@letux:~#

Test BSD:

iMac:master hns$ echo foo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo fool | egrep '^(foo)?$'
egrep: empty (sub)expression
iMac:master hns$ echo fun | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo f | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo foo | egrep '^(foo)?$'
foo
iMac:master hns$ echo fool | egrep '^(foo)?$'
iMac:master hns$ echo fun | egrep '^(foo)?$'
iMac:master hns$ echo f | egrep '^(foo)?$'
iMac:master hns$ echo | egrep '^(foo)?$'

iMac:master hns$

H. Nikolaus Schaller (2):
x86/tools/relocs: Fix non-POSIX regexp
arch: mips: Fix non-POSIX regexp

arch/mips/Makefile | 2 +-
arch/x86/tools/relocs.c | 8 ++++----

2 files changed, 5 insertions(+), 5 deletions(-)

--
2.31.1

Signature · 2 lines
Thanks,
~Nick Desaulniers
#8 lore raw
Quoted 5 lines · H. Nikolaus Schaller

Hi all,
any chance to get that reviewed and merged into v5.15-rc1 and backported to stable? Thank you,
Nikolaus Schaller

I have a macbook (macOS catalina), and was able to reproduce this issue.

I applied both to kbuild tree.
Thanks.

Quoted 107 lines
Quoted 106 lines

Am 19.07.2021 um 22:37 schrieb Nick Desaulniers <[email protected]>:

+ Masahiro, linux-kbuild (EOM)

Quoted 95 lines · H. Nikolaus Schaller

Any chance that it gets merged?

Quoted 91 lines

Am 08.07.2021 um 10:57 schrieb H. Nikolaus Schaller <[email protected]>:

Trying to run the x86 relocs tool on a BSD based HOSTCC (cross compilation environment) 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 compiling a MIPS kernel on a BSD based HOSTCC we get errors like

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 on x86 uses patterns like

     "something(|_end)"

while MIPS uses egrep with

     (|MINOR_|PATCHLEVEL_)

In both cases it is not valid syntax or gives undefined results according to POSIX 9.5.3 ERE Grammar

     https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux regcmp() or egrep implementation while a BSD host complains.

Such patterns can be replaced by a transformation like

     "(|p1|p2)" -> "(p1|p2)?"

Test Linux:

root@letux:~# echo foo | egrep '^(|foo)$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(|foo)$'
root@letux:~# echo f | egrep '^(|foo)$'
root@letux:~# echo | egrep '^(|foo)$'
root@letux:~# echo foo | egrep '^(foo)?$'
foo
root@letux:~# echo fool | egrep '^(foo)?$'
root@letux:~# echo fun | egrep '^(foo)?$'
root@letux:~# echo f | egrep '^(foo)?$'
root@letux:~# echo | egrep '^(foo)?$'

root@letux:~#

Test BSD:

iMac:master hns$ echo foo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo fool | egrep '^(foo)?$'
egrep: empty (sub)expression
iMac:master hns$ echo fun | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo f | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo foo | egrep '^(foo)?$'
foo
iMac:master hns$ echo fool | egrep '^(foo)?$'
iMac:master hns$ echo fun | egrep '^(foo)?$'
iMac:master hns$ echo f | egrep '^(foo)?$'
iMac:master hns$ echo | egrep '^(foo)?$'

iMac:master hns$

H. Nikolaus Schaller (2):
x86/tools/relocs: Fix non-POSIX regexp
arch: mips: Fix non-POSIX regexp

arch/mips/Makefile | 2 +-
arch/x86/tools/relocs.c | 8 ++++----

2 files changed, 5 insertions(+), 5 deletions(-)

--
2.31.1

--
Thanks,
~Nick Desaulniers

Signature · 2 lines
Best Regards
Masahiro Yamada