diff mbox series

Fix awk substr invocation in libgo buildsystem

Message ID 20210510093241.184528-1-choeger@umpa-net.de
State New
Headers show
Series Fix awk substr invocation in libgo buildsystem | expand

Commit Message

Christoph Höger May 10, 2021, 9:32 a.m. UTC
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(-)

Comments

Jeff Law May 13, 2021, 7:09 p.m. UTC | #1
On 5/10/2021 3:32 AM, Christoph Höger wrote:
> 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(-)

I believe this file is managed by the upstream golang project. So the 
submission should go to them.  The guidelines from the README file:

Contributing
============

To contribute patches to the files in this directory, please see
http://golang.org/doc/gccgo_contribute.html .

The master copy of these files is hosted at
http://code.google.com/p/gofrontend .  Changes to these files require
signing a Google contributor license agreement.  If you are the
copyright holder, you will need to agree to the individual contributor
license agreement at
http://code.google.com/legal/individual-cla-v1.0.html.  This agreement
can be completed online.

If your organization is the copyright holder, the organization will
need to agree to the corporate contributor license agreement at
http://code.google.com/legal/corporate-cla-v1.0.html.

If the copyright holder for your code has already completed the
agreement in connection with another Google open source project, it
does not need to be completed again.

--


Thanks,

Jeff
diff mbox series

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.