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: HP-UX IA64 patch for section usage.


On Tue, Oct 29, 2002 at 01:01:55PM -0800, Steve Ellcey wrote:
> 
> I'd love to give a good explanation for this patch but the person who
> made it has left and all I really know is that I need it for C++ to work
> on IA64 HP-UX.  Without this change, using the HP linker I get a lot of
> messages like:
> 
> 	ld: Invalid dynamic relocation needed for read-only section, in finput file /var/tmp//ccLCTeOg.o, for symbol vtable for __cxxabiv1::__vmi_class_type_infoat offset 0
> 
> I am hoping someone with a better understanding of linkers and data
> sections can look at it and understand why it is needed and approve
> the patch.

This should definitely be handled via some hook or something - 
at least on ELF arches which use R_<arch>_COPY relocs 
!shlib && reloc should go into SECCAT_RODATA (see the patch I posted
yesterday, they shouldn't go into the SHF_MERGE sections).
But even for HP-UX, I wonder if you really need reloc -> SECCAT_DATA_REL_RO
(note not SECCAT_DATA_REL) and not just (reloc & 2) -> SECCAT_DATA_REL_RO,
reloc -> SECCAT_RODATA, ie. whether even relocations at link time
must never go into .rodata section.

Alternatively, we could remove 'shlib && ' unconditionally, hack
up the compiler so that it if (!flag_pic), sets SECCAT_DATA_REL_RO and
SECCAT_DATA_REL_RO_LOCAL section flags to "a", not "aw" and let the linker
decide whether to put them into .data or .rodata based on whether linking
-shared or not.

> Here is the change that fixes my C++ test failures:
> 
> 
> 2002-10-29  Steve Ellcey  <sje@cup.hp.com>
> 
> 	* varasm.c (categorize_decl_for_section): Handle reloc section.
> 
> 
> *** gcc.orig/gcc/varasm.c	Tue Oct 29 12:47:24 2002
> --- gcc/gcc/varasm.c	Tue Oct 29 12:48:26 2002
> *************** categorize_decl_for_section (decl, reloc
> *** 5060,5065 ****
> --- 5060,5067 ----
>   	ret = SECCAT_DATA_REL_RO;
>         else if (shlib && reloc)
>   	ret = SECCAT_DATA_REL_RO_LOCAL;
> +       else if (reloc)
> + 	ret = SECCAT_DATA_REL;
>         else if (flag_merge_constants < 2)
>   	/* C and C++ don't allow different variables to share the same
>   	   location.  -fmerge-all-constants allows even that (at the

	Jakub


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