Commit 95b4498a authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/internal/obj/arm64: don't crash on trailing NOP

Fixes #20348

Change-Id: I831aeeee8e20d55b3e47dea67786e883b213cd58
Reviewed-on: https://go-review.googlesource.com/106457
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarAram Hăvărneanu <aram@mgk.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 641c3226
......@@ -61,3 +61,21 @@ func gen(buf *bytes.Buffer) {
fmt.Fprintln(buf, "label:")
fmt.Fprintln(buf, "RET")
}
// Issue 20348.
func TestNoRet(t *testing.T) {
dir, err := ioutil.TempDir("", "testnoret")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
tmpfile := filepath.Join(dir, "x.s")
if err := ioutil.WriteFile(tmpfile, []byte("TEXT ·stub(SB),$0-0\nNOP\n"), 0644); err != nil {
t.Fatal(err)
}
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
cmd.Env = []string{"GOARCH=arm64", "GOOS=linux"}
if out, err := cmd.CombinedOutput(); err != nil {
t.Errorf("%v\n%s", err, out)
}
}
......@@ -476,9 +476,11 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
break
case obj.ANOP:
if p.Link != nil {
q1 = p.Link
q.Link = q1 /* q is non-nop */
q1.Mark |= p.Mark
}
continue
case ABL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment