This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] VAX ELF PIC support.



On Sunday, September 21, 2003, at 01:28 PM, Richard Henderson wrote:


On Sat, Sep 20, 2003 at 10:28:50AM -0700, Matt Thomas wrote:
+#undef CC1_SPEC
+#define CC1_SPEC \
+  "%{!fno-pic: \
+     %{!fno-pie: \
+       %{!fpic: \
+         %{!fpie: \
+           %{!fPIC: \
+             %{!fPIE:-fPIC}}} \
+       %{!mindirect: \
+         %{!mno-indirect:-mno-indirect}}}}} \
+   %{fno-pic:-fno-pic \
+     %{!mno-indirect: \
+       %{!mindirect:-mindirect}}} \
+   %{fno-pie:-fno-pie \
+     %{!mno-indirect: \
+       %{!mindirect:-mindirect}}}"

I'm amazed you want to make this the default.

The VAX is designed for PIC. By default, all VAX code is PIC. In fact, the use of PIC results in smaller and faster code. The only reason GCC didn't emit PIC code was that it treated SYMBOL_REFs and LABEL_REFs as immediate operands instead of using the VAX move-adress/push-address instructions to get the address in a PIC manner.

But this is most definitely the wrong way to do it.

Probably, but I still need to do the above -mindirect.


Add a FLAG_PIC_DEFAULT/FLAG_PIE_DEFAULT define, and set
flag_pic/flag_pie to that in toplev.c.  Set it to -1 by
default and fix things up in override options.

I was hoping to not affect things other in config/vax.


+/* Pass -k to the assembler by default, since we generate PIC code by
+ default (-fPIC above), unless -fno-pic or -mno-asm-pic is passed. */
+#undef ASM_SPEC
+#define ASM_SPEC \
+ "%{!fno-pic: \
+ %{!fno-pie: \
+ %{!mno-asm-pic:-k}}}"

Ug. Assemblers have no buisiness knowing about such flags. Since I can't imagine that VAX pic support has existed in the assembler for long, I would ask that you fix this. At minimum the assembler should provide a way to get at the relocations directly so that the compiler can know exactly what it's generating.

The PIC model is similar as taken with VMS. The assembler does no magic, it all in the linker. This is the way the VAX was designed to work. It's been working for well over a year on NetBSD without a problem.

The linker can trivially change (if non linking shared) a:

movl foo@GOT,%r0

insto

movl foo,%r0

by simply flipping a bit in the operand byte. The rest is handled by the
linker (not the assembler). This is identical in spirit to how VAX/VMS
does things and it really is the right thing for VAX.


+ assert (REGNO (addr) < 16);

We don't use assert in gcc.

OK. So how does one verify that a correct register is being emitted?


+/* When generating PIC code, SYMBOL_REF_FLAG is set for
+   symbols which are public.  */
+
+static void
+vax_encode_section_info (tree decl, rtx rtl, int first)

You shouldn't need this at all. The test you are looking for is already present as !SYMBOL_REF_LOCAL_P.

Ahhh. I did find that SYMBOL_REF_EXTERNAL_P wasn't right so ...


The rest of the patch wasn't really comprehensible to me since
I don't know what the vax pic model looks like, since you've
hidden it entirely in the assembler.

The linker, not the assembler, which, as I said above, is
appropriate for VAX.
--
Matt Thomas email: matt@3am-software.com
3am Software Foundry www: http://3am-software.com/bio/matt/
Cupertino, CA disclaimer: I avow all knowledge of this message.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]