Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Tom Tkacik
Wed, 24 Aug 1988 18:43
bug in gcc-1.24 for the 3B1
Author: Tom Tkacik
Date: Wed, 24 Aug 1988 18:43
Date: Wed, 24 Aug 1988 18:43
186 lines
6742 bytes
6742 bytes
There is a bug in the gcc compiler for the AT&T 3B1.
The 3B1 pcc is one of the few compilers that does not tack on an initial
underscore to all global variables in any assembly code.
Instead it places a '%' in all of the compiler generated labels.
Gcc does not do this, so it is possible to get name conflicts between
global variables and gcc generated labels and static variables.
----------------------------------------------
SYSTEM:
AT&T 3B1 running SYS V.? (release 3.5)
FILES:
tm.h -----> tm-3b1.h
md -----> m68k.md
VERSION:
GNU C version 1.24 (68k, SGS/AT&T unixpc syntax) compiled by GNU C version 1.24.
----------------------------------------------
The following very short program produces two errors.
int L1, i___0;
main()
{
static i;
}
----------------------------------------------
The following output is from gcc -v -S bug.s, and will not assemble with as.
lcomm i___0,4 <-- gcc generated static label
text (should be i%__0)
even
global main
main:
link.w %a6,&0
L1: <-- gcc generated label (should be L%1:)
unlk %a6
rts
comm i___0,4 <-- global variable
comm L1,4 <-- global variable (note: no leading '_')
----------------------------------------------
The version of gcc is
$ gcc -v -S bug.c
/usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dmc68k -Dm68k -Dunix -Dunixpc bug.c /tmp/cca01091.cpp
GNU CPP version 1.24
/usr/local/lib/gcc-cc1 /tmp/cca01091.cpp -quiet -dumpbase bug.c -version -o /tmp/cca01091.s
GNU C version 1.24 (68k, SGS/AT&T unixpc syntax) compiled by GNU C version 1.24.
----------------------------------------------
The fix is in tm-3b1.h. All gcc generated labels and static variables
need to have a '%' imbedded them somewhere, (this is what cc does).
The following are my patches to tm-3b1.h to fix the problem, plus a couple
of typos. I believe they fix all occurances of gcc generated labels and
static variable names.
Tom Tkacik
...!rphroy!tetnix!tet
--------------------------------------------
*** tm-3b1.h.orig Thu Aug 4 22:07:50 1988
--- tm-3b1.h Sat Aug 20 19:05:54 1988
***************
*** 59,64 ****
--- 59,65 ----
/* Define __HAVE_FPU__ in preprocessor if -m68881 is specified.
This will control the use of inline 68881 insns in certain macros. */
+ #undef CPP_SPEC
#define CPP_SPEC "%{m68881:-D__HAVE_FPU__}"
/* Names to predefine in the preprocessor for this target machine. */
***************
*** 76,81 ****
--- 77,86 ----
#undef ASM_OUTPUT_SOURCE_LINE
#undef PRINT_OPERAND_ADDRESS
#undef ASM_OUTPUT_INTERNAL_LABEL
+ #undef ASM_OUTPUT_ADDR_VEC_ELT
+ #undef ASM_OUTPUT_ADDR_DIFF_ELT
+ #undef ASM_GENERATE_INTERNAL_LABEL
+ #undef ASM_FORMAT_PRIVATE_NAME
#undef ASM_OUTPUT_OPCODE
#undef ASM_OUTPUT_LOCAL
#undef ASM_OUTPUT_LABELREF
***************
*** 232,242 ****
{ scale = INTVAL (XEXP (ireg, 1)); \
ireg = XEXP (ireg, 0); } \
if (GET_CODE (ireg) == SIGN_EXTEND) \
! fprintf (FILE, "LD%d(%%pc,%s.w", \
CODE_LABEL_NUMBER (XEXP (addr, 0)), \
reg_name[REGNO (XEXP (ireg, 0))]); \
else \
! fprintf (FILE, "LD%d(%%pc,%s.l", \
CODE_LABEL_NUMBER (XEXP (addr, 0)), \
reg_name[REGNO (ireg)]); \
if (scale != 1) fprintf (FILE, ":%d", scale); \
--- 237,247 ----
{ scale = INTVAL (XEXP (ireg, 1)); \
ireg = XEXP (ireg, 0); } \
if (GET_CODE (ireg) == SIGN_EXTEND) \
! fprintf (FILE, "LD%%%d(%%pc,%s.w", \
CODE_LABEL_NUMBER (XEXP (addr, 0)), \
reg_name[REGNO (XEXP (ireg, 0))]); \
else \
! fprintf (FILE, "LD%%%d(%%pc,%s.l", \
CODE_LABEL_NUMBER (XEXP (addr, 0)), \
reg_name[REGNO (ireg)]); \
if (scale != 1) fprintf (FILE, ":%d", scale); \
***************
*** 263,269 ****
break; \
} \
else if (reg1 != 0 && GET_CODE (addr) == LABEL_REF) \
! { fprintf (FILE, "LD%d(%%pc,%s.w)", \
CODE_LABEL_NUMBER (XEXP (addr, 0)), \
reg_name[REGNO (reg1)]); \
break; } \
--- 268,274 ----
break; \
} \
else if (reg1 != 0 && GET_CODE (addr) == LABEL_REF) \
! { fprintf (FILE, "LD%%%d(%%pc,%s.w)", \
CODE_LABEL_NUMBER (XEXP (addr, 0)), \
reg_name[REGNO (reg1)]); \
break; } \
***************
*** 277,291 ****
}}
#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
! fprintf (FILE, "%s%d:\n", PREFIX, NUM)
#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
! fprintf (FILE, "\tswbeg &%d\n%s%d:\n\tshort 0\n", \
XVECLEN (PATTERN (TABLE), 1) + 1, PREFIX, NUM)
#define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
! fprintf (FILE, "\tset LD%d,L%d-LI%d\n", NUM, NUM, NUM);
#define ASM_OUTPUT_OPCODE(FILE, PTR) \
{ if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
{ ++(PTR); \
--- 282,309 ----
}}
#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
! fprintf (FILE, "%s%%%d:\n", PREFIX, NUM)
+ #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
+ fprintf (FILE, "\tlong L%%%d\n", VALUE)
+
+ #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
+ fprintf (FILE, "\tshort L%%%d-L%%%d\n", VALUE, REL)
+
#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
! fprintf (FILE, "\tswbeg &%d\n%s%%%d:\n\tshort 0\n", \
XVECLEN (PATTERN (TABLE), 1) + 1, PREFIX, NUM)
#define ASM_OUTPUT_CASE_END(FILE,NUM,TABLE) \
! fprintf (FILE, "\tset LD%%%d,L%%%d-LI%%%d\n", NUM, NUM, NUM)
+ #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
+ sprintf (LABEL, "*%s%%%d", PREFIX, NUM)
+
+ #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
+ ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 12), \
+ sprintf ((OUTPUT), "%s%%__%d", (NAME), (LABELNO)))
+
#define ASM_OUTPUT_OPCODE(FILE, PTR) \
{ if ((PTR)[0] == 'j' && (PTR)[1] == 'b') \
{ ++(PTR); \
***************
*** 326,328 ****
--- 344,349 ----
#define ASM_OUTPUT_LABELREF(FILE,NAME) \
fprintf (FILE, "%s", NAME)
+
+ #define SDB_DEBUGGING_INFO
+
----------------------------------------------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads