Better error message for .globl 1$

Local labels can't be exported (or imported).
This commit is contained in:
Olaf Seibert
2021-05-30 12:57:37 +02:00
parent 0ab2a4fa16
commit 652c047711
3 changed files with 21 additions and 5 deletions

View File

@@ -1131,16 +1131,22 @@ static int assemble(
case P_GLOBL:
{
SYMBOL *sym;
int islocal = 0;
while (!EOL(*cp)) {
/* Loop and make definitions for
comma-separated symbols */
label = get_symbol(cp, &ncp, NULL);
label = get_symbol(cp, &ncp, &islocal);
if (label == NULL) {
report(stack->top, "Illegal .GLOBL/.WEAK syntax\n");
return 0;
}
if (islocal) {
report(stack->top, "Local label used in .GLOBL/.WEAK\n");
return 0;
}
sym = lookup_sym(label, &symbol_st);
if (sym) {
sym->flags |= SYMBOLFLAG_GLOBAL | (op->value == P_WEAK ? SYMBOLFLAG_WEAK : 0);

View File

@@ -11,16 +11,22 @@
test-gbl.mac:11: ***ERROR Invalid expression (complex relocation)
11 000004 012700 000000 mov #lab2,r0 ; error: undefined
12
13 .end
13
test-gbl.mac:13: ***ERROR Local label used in .GLOBL/.WEAK
13 .globl 1$ ; error: locals can't be globals too
test-gbl.mac:14: ***ERROR Local label used in .GLOBL/.WEAK
14 .globl 2$ ; error: locals can't be globals too
15 000010 012700 000010' 1$: mov #1$,r0
16
17 .end
17
Symbol table
. 000010R 001 LAB1 = ****** GX LAB2 = ******
. 000014R 001 1$0 000010R L 001 LAB1 = ****** GX LAB2 = ******
Program sections:
. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV)
000010 001 (RW,I,LCL,REL,CON,NOSAV)
000014 001 (RW,I,LCL,REL,CON,NOSAV)

View File

@@ -10,4 +10,8 @@
.dsabl gbl
mov #lab2,r0 ; error: undefined
.globl 1$ ; error: locals can't be globals too
.globl 2$ ; error: locals can't be globals too
1$: mov #1$,r0
.end