Fix awk substr invocation in libgo buildsystem

Message ID 20210510084744.182059-1-choeger@umpa-net.de
State Superseded
Headers show
Series
  • Fix awk substr invocation in libgo buildsystem
Related show

Commit Message

Christoph Höger May 10, 2021, 8:47 a.m.
The awk script used a zero-based index which worked on surprisingly
many plattforms. According to the man page, however, the function
expects one-based indexing.

For reference see this bug in the go git repository:

https://github.com/golang/go/issues/45843

Signed-off-by: Christoph Höger <choeger@umpa-net.de>

---
 ChangeLog             | 4 ++++
 libgo/mklinknames.awk | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.31.1

Patch

diff --git a/ChangeLog b/ChangeLog
index 2174ab1ea90..495e6f79b76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@ 
+2021-05-10  Christoph Höger  <choeger@umpa-net.de>
+
+	* libgo/mklinknames.awk: Fix awk substr invocation
+
 2021-05-04  Nick Clifton  <nickc@redhat.com>
 
 	* configure.ac (AC_PROG_CC): Replace with AC_PROG_CC_C99.
diff --git a/libgo/mklinknames.awk b/libgo/mklinknames.awk
index 71cb3be7966..0e49c07349e 100644
--- a/libgo/mklinknames.awk
+++ b/libgo/mklinknames.awk
@@ -37,7 +37,7 @@  BEGIN {
     # The goal is to extract "__timegm50".
     if ((def | getline fndef) > 0 && match(fndef, "__asm__\\(\"\\*?")) {
 	asmname = substr(fndef, RSTART + RLENGTH)
-	asmname = substr(asmname, 0, length(asmname) - 2)
+	asmname = substr(asmname, 1, length(asmname) - 2)
 	printf("//go:linkname %s %s\n", gofnname, asmname)
     } else {
 	# Assume the asm name is the same as the declared C name.