https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129224
Bug ID: 129224
Summary: [PDP11] Misformed function labels used in `jsr`
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: julia.desmazes at gmail dot com
Target Milestone: ---
Created attachment 66364
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66364&action=edit
result of `-save-temps`
Hello,
I have stumbled onto an issue when compiling for the PDP11 target where the
generated assembly uses misformed function labels on the `JSR` (jump to
subroutine) instruction.
Minimal code to reproduce:
bug.c:
```
int main(){
return 0;
}
```
Compile:
`pdp11-dec-aout-gcc -v -save-temps -nostdlib bug.c -o bug`
Intermediary assembly (gcc format):
```
.text
.even
.globl _main
_main:
setd
seti
mov r5,-(sp)
mov sp,r5
jsr pc,___main // expecting _main
clr r0
mov (sp)+,r5
rts pc
```
Resulting in the linker error `(.text+0xa): undefined reference to `__main'`.
Of note I have observed that the same issue of having two extra underscores
`__` before the function label also occurs when compiling to the dec assembly.
Editing the asm files by hand solves the issue.
Setup:
host machine: x86_64 22.04.1-Ubuntu
gcc version: pdp11-dec-aout-gcc (GCC) 16.2.0
gcc configuration: --target=pdp11-dec-aout --prefix=/home/gp/opt/cross
--disable-nls --enable-languages=c --without-headers
binutils version: binutils-with-gold-2.46
binutils configuration: --with-sysroot --disable-nls --disable-werror
--enable-default-execstack=no
Thanks for all you do and for keeping the pdp11 toolchain alive.
No AI was used in finding this bug or writing this report.