This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: `$' in identifiers -vs- PPC Linux
- To: Geoff Keating <geoffk at cygnus dot com>,Franz dot Sirl-kernel at lauterbach dot com
- Subject: Re: `$' in identifiers -vs- PPC Linux
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Tue, 17 Oct 2000 23:01:50 +0200
- Cc: gcc-patches at gcc dot gnu dot org
- References: <Tom Tromey's message of "30 Aug 2000 15:25:22 -0600"> <00101721375300.01666@enzo.bigblue.local> <200010172019.NAA01309@geoffk.org>
On Tue, 17 Oct 2000, Geoff Keating wrote:
> > From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
> > Date: Tue, 17 Oct 2000 21:37:53 +0200
> > Cc: gcc-patches@gcc.gnu.org
> >
> > Well, tell me what do you want to have out of rs6000.h and I'll do
> > the boring work :-). I just couldn't draw a sensible line for all
> > the alignment, type and ASM macros myself.
>
> I think that when the ppc-elf64 stuff comes in all this will need to
> be rearranged anyway, because suddenly we'll have aix-xcoff and
> aix-elf64 and powerpc-elf64. So there's no need to tinker with it now.
OK :)
> > > > > make no real sense to move into aix.h IMHO.
> > > > >
> > > > > The patch also syncs the ASM_APP_* macros for Linux on PPC and
> > > > > fixes the CONSTRUCTOR handling in rs6000.c. Geoff, related to the
> > > > > CONSTRUCTOR handling I also want to revive execute/20000516-1.c
> > > > > from CVS, this test is meant to pass and is _different_ from
> > > > > execute/20000722-1.c. The test verifies that CONSTRUCTOR data is
> > > > > put into a writeable section. I didn't notice yet that you did
> > > > > remove it, but the removal was wrong.
> > >
> > > The testcase was failing sometimes, and passing sometimes, based I
> > > believe on segment sizes or something, which was annoying.
> > >
> > > The data does not need to be put in a writable section. It has to be
> > > copied from wherever it is into a local temporary.
> > >
> > > For instance,
> > >
> > > struct s
> > > {
> > > int value;
> > > char *string;
> > > };
> > >
> > > int i;
> > > for (i = 0; i < 4; i++)
> > > {
> > > struct s *t = & (struct s) { 3, "hey there" };
> > > if (t->value != 3)
> > > abort();
> > > t->value = 4;
> > > if (t->value != 4)
> > > abort();
> > > }
> >
> > I don't quite understand? This code fails without my patch and passes
> > with it?
>
> No, this code fails on every gcc release to date I believe. Certainly
> it fails on x86 and ppc with current gcc versions. But C99 says it
> should pass.
>
> > Note that my patch (or something similar) fixes Linux kernel compilation,
> > without it you can't put a kernel image into ROM, cause it tries to write
> > to it. This is a showstopper for the embedded people. Additionally the
> > same functionality is available on x86, which passed the testcase too.
>
> Your patch fixes this specific problem, but the underlying bug is
> still there, and if the underlying bug was fixed your patch would
> probably be unnecessary. Your patch is OK for a branch, but not for
> the mainline.
>
> > On what platforms did the test FAIL?
>
> I had to take your test out because it would fail or pass depending on
> the size of crt0, which was confusing the automated tester. The new
> testcase shows the same underlying problem (that we aren't using
> temporaries) and fails every time.
>
> > I would rather think these need fixes too, that's why the testcase
> > was added in the first place, it tests if the functionality (I think
> > this is a GCC extension) is correctly implemented.
>
> It's now in the ISO C standard, as section 6.5.2.5, with
> better-defined semantics. The bit that would need changing is
> cast_expr in c-parse.in.
Aaahhh! So you meant to say there _is_ a bug, but it has to be fixed in a
different way. Fine with me.
Here is the updated patch, OK to commit?
BTW, can you approve this PPC related fix too? It's in my sources for nearly
a year now and awaits approval :-):
http://gcc.gnu.org/ml/gcc-patches/1999-11n/msg00616.html
Some related discussion can be found here:
http://gcc.gnu.org/ml/gcc-patches/1999-11n/msg00268.html
Franz.
* rs6000/rs6000.h (NO_DOLLAR_IN_LABEL, DOLLARS_IN_IDENTIFIERS,
ENCODE_SECTION_INFO, ASM_OUTPUT_SPECIAL_POOL_ENTRY_P): Move from
here...
* rs6000/aix.h: ...to here.
* rs6000/linux.h (ASM_APP_ON, ASM_APP_OFF): Define to Linux-style.
Index: aix.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/aix.h,v
retrieving revision 1.7
diff -u -p -r1.7 aix.h
--- aix.h 2000/08/22 19:27:31 1.7
+++ aix.h 2000/08/31 19:30:42
@@ -50,6 +50,17 @@ Boston, MA 02111-1307, USA. */
#define FASCIST_ASSEMBLER
+/* We define this to prevent the name mangler from putting dollar signs into
+ function names. */
+
+#define NO_DOLLAR_IN_LABEL
+
+/* We define this to 0 so that gcc will never accept a dollar sign in a
+ variable name. This is needed because the AIX assembler will not accept
+ dollar signs. */
+
+#define DOLLARS_IN_IDENTIFIERS 0
+
/* AIX does not have any init/fini or ctor/dtor sections, so create
static constructors and destructors as normal functions. */
/* #define ASM_OUTPUT_CONSTRUCTOR(file, name) */
@@ -227,6 +238,30 @@ toc_section () \
} \
}
+/* Return non-zero if this entry is to be written into the constant
+ pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
+ or a CONST containing one of them. If -mfp-in-toc (the default),
+ we also do this for floating-point constants. We actually can only
+ do this if the FP formats of the target and host machines are the
+ same, but we can't check that since not every file that uses
+ GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when
+ we can write the entry into the TOC and the entry is not larger
+ than a TOC entry. */
+
+#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
+ (TARGET_TOC \
+ && (GET_CODE (X) == SYMBOL_REF \
+ || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
+ && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
+ || GET_CODE (X) == LABEL_REF \
+ || (GET_CODE (X) == CONST_INT \
+ && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
+ || (GET_CODE (X) == CONST_DOUBLE \
+ && (TARGET_POWERPC64 \
+ || TARGET_MINIMAL_TOC \
+ || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
+ && ! TARGET_NO_FP_IN_TOC)))))
+
/* Select section for constant in constant pool.
On RS/6000, all constants are in the private read-only data area.
@@ -239,6 +274,17 @@ toc_section () \
else \
read_only_private_data_section (); \
}
+
+/* If we are referencing a function that is static or is known to be
+ in this file, make the SYMBOL_REF special. We can use this to indicate
+ that we can branch to this function without emitting a no-op after the
+ call. Do not set this flag if the function is weakly defined. */
+
+#define ENCODE_SECTION_INFO(DECL) \
+ if (TREE_CODE (DECL) == FUNCTION_DECL \
+ && (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL)) \
+ && ! DECL_WEAK (DECL)) \
+ SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;
/* Indicate that jump tables go in the text section. */
Index: linux.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/linux.h,v
retrieving revision 1.19
diff -u -p -r1.19 linux.h
--- linux.h 2000/04/14 23:16:25 1.19
+++ linux.h 2000/08/31 19:30:42
@@ -54,6 +54,14 @@ Boston, MA 02111-1307, USA. */
#undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)");
+/* Override rs6000.h definition. */
+#undef ASM_APP_ON
+#define ASM_APP_ON "#APP\n"
+
+/* Override rs6000.h definition. */
+#undef ASM_APP_OFF
+#define ASM_APP_OFF "#NO_APP\n"
+
#undef DEFAULT_VTABLE_THUNKS
#ifndef USE_GNULIBC_1
#define DEFAULT_VTABLE_THUNKS 1
Index: rs6000.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.90
diff -u -p -r1.90 rs6000.h
--- rs6000.h 2000/08/14 05:59:50 1.90
+++ rs6000.h 2000/08/31 19:30:55
@@ -2327,17 +2327,6 @@ extern int rs6000_trunc_used;
the end of the line. */
#define ASM_COMMENT_START " #"
-/* We define this to prevent the name mangler from putting dollar signs into
- function names. */
-
-#define NO_DOLLAR_IN_LABEL
-
-/* We define this to 0 so that gcc will never accept a dollar sign in a
- variable name. This is needed because the AIX assembler will not accept
- dollar signs. */
-
-#define DOLLARS_IN_IDENTIFIERS 0
-
/* Implicit library calls should use memcpy, not bcopy, etc. */
#define TARGET_MEM_FUNCTIONS
@@ -2348,43 +2337,8 @@ extern int rs6000_trunc_used;
#define EXCEPTION_SECTION data_section
-/* If we are referencing a function that is static or is known to be
- in this file, make the SYMBOL_REF special. We can use this to indicate
- that we can branch to this function without emitting a no-op after the
- call. Do not set this flag if the function is weakly defined. */
-
-#define ENCODE_SECTION_INFO(DECL) \
- if (TREE_CODE (DECL) == FUNCTION_DECL \
- && (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL)) \
- && ! DECL_WEAK (DECL)) \
- SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;
-
/* Flag to say the TOC is initialized */
extern int toc_initialized;
-
-/* Return non-zero if this entry is to be written into the constant
- pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
- or a CONST containing one of them. If -mfp-in-toc (the default),
- we also do this for floating-point constants. We actually can only
- do this if the FP formats of the target and host machines are the
- same, but we can't check that since not every file that uses
- GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when
- we can write the entry into the TOC and the entry is not larger
- than a TOC entry. */
-
-#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
- (TARGET_TOC \
- && (GET_CODE (X) == SYMBOL_REF \
- || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
- && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
- || GET_CODE (X) == LABEL_REF \
- || (GET_CODE (X) == CONST_INT \
- && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
- || (GET_CODE (X) == CONST_DOUBLE \
- && (TARGET_POWERPC64 \
- || TARGET_MINIMAL_TOC \
- || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
- && ! TARGET_NO_FP_IN_TOC)))))
/* Macro to output a special constant pool entry. Go to WIN if we output
it. Otherwise, it is written the usual way.