https://sourceware.org/bugzilla/show_bug.cgi?id=35012
Bug ID: 35012
Summary: bpf: gas silently wraps out-of-range jump offsets with
-misa-spec=v1..v3
Product: binutils
Version: 2.47
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gas
Assignee: unassigned at sourceware dot org
Reporter: mumumu0722 at gmail dot com
Target Milestone: ---
With -misa-spec=v1, v2 or v3 (or with -mno-relax), gas accepts a conditional
jump whose offset does not fit in the signed 16-bit offset field, and the
offset wraps around. Here the jump over 40000 instructions becomes `goto
-25536`, a backward jump out of the code.
$ bpf-as --version
GNU assembler (GNU Binutils) 2.47.50.20261116
....
$ cat t.s
if r1 == 0 goto 1f
.rept 40000
r0 = r0
.endr
1: exit
$ bpf-as -mdialect=pseudoc -misa-spec=v3 t.s -o t.o
$ bpf-objdump -d -M pseudoc --no-show-raw-insn t.o
...
0: if r1==0 goto -25536
...
4e208: exit
Expected: an error, because +40000 is outside -32768..32767 and ISA v3 has no
long jump.
Offsets up to 32767 are correct.
With the default -misa-spec=v4, the jump is relaxed correctly:
$ bpf-as -mdialect=pseudoc t.s -o t.o
$ bpf-objdump -d -M pseudoc --no-show-raw-insn t.o
0: if r1==0 goto 1
8: goto 1
10: gotol 40000
4e218: exit
Found by automated testing.
--
You are receiving this mail because:
You are on the CC list for the bug.