This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patches] Re: KDE a gcc
- From: Jan Hubicka <jh at suse dot cz>
- To: Richard Henderson <rth at redhat dot com>, Jan Hubicka <jh at suse dot cz>, Lubos Lunak <l dot lunak at sh dot cvut dot cz>, Jakub Jelinek <jakub at redhat dot com>, gcc-patches at gcc dot gnu dot org, patches at x86-64 dot org
- Date: Mon, 19 Nov 2001 15:57:54 +0100
- Subject: Re: [patches] Re: KDE a gcc
- References: <200110030715.f937FCT75772@ns.felk.cvut.cz> <200110312108.WAA21661@stoupa.sh.cvut.cz> <20011101145241.E31305@atrey.karlin.mff.cuni.cz> <200111011733.SAA25987@stoupa.sh.cvut.cz> <20011112155258.H8833@atrey.karlin.mff.cuni.cz> <20011112155951.K8833@atrey.karlin.mff.cuni.cz> <20011112092319.A15349@redhat.com>
> On Mon, Nov 12, 2001 at 03:59:51PM +0100, Jan Hubicka wrote:
> > * output.h (data_rel_section, data_rel_ro_section): Declare.
> > * varasm.c (in_section): Add in_data_rel and in_data_rel_ro.
> > (default_exception_section): Use data_rel_ro_section.
> > (output_constant_def_components): Likewise.
>
> I'd rather you handled this entirely in SELECT_SECTION.
Hi,
here is updated patch that does so and adds the local/global flag
requested by Jakub. Hope it is OK now.
Bootstrapped mainline.
Mon Nov 19 15:53:29 CET 2001 Jan Hubicka <jh@suse.cz>
* varasm.c (assemble_variable): Set reloc to 3 for error_mark
containing pointers.
(output_addressed_constants): Check for local/external relocations.
* elfos.h (SELECT_SECTION): Classify data section.
* tm.texi (SELECT_SECTION): Update documentation.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.226
diff -c -3 -p -r1.226 varasm.c
*** varasm.c 2001/11/11 05:56:36 1.226
--- varasm.c 2001/11/19 14:53:17
*************** assemble_variable (decl, top_level, at_e
*** 1676,1682 ****
/* Output any data that we will need to use the address of. */
if (DECL_INITIAL (decl) == error_mark_node)
! reloc = contains_pointers_p (TREE_TYPE (decl));
else if (DECL_INITIAL (decl))
reloc = output_addressed_constants (DECL_INITIAL (decl));
--- 1676,1682 ----
/* Output any data that we will need to use the address of. */
if (DECL_INITIAL (decl) == error_mark_node)
! reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0;
else if (DECL_INITIAL (decl))
reloc = output_addressed_constants (DECL_INITIAL (decl));
*************** output_addressed_constants (exp)
*** 4204,4212 ****
tree constant = TREE_OPERAND (exp, 0);
while (TREE_CODE (constant) == COMPONENT_REF)
! {
! constant = TREE_OPERAND (constant, 0);
! }
if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
|| TREE_CODE (constant) == CONSTRUCTOR)
--- 4204,4217 ----
tree constant = TREE_OPERAND (exp, 0);
while (TREE_CODE (constant) == COMPONENT_REF)
! constant = TREE_OPERAND (constant, 0);
!
! if (TREE_CODE (constant) == CONSTRUCTOR)
! reloc = 1;
! else if (TREE_PUBLIC (constant))
! reloc |= 2;
! else
! reloc |= 1;
if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
|| TREE_CODE (constant) == CONSTRUCTOR)
*************** output_addressed_constants (exp)
*** 4214,4220 ****
for addresses of variables or functions. */
output_constant_def (constant, 0);
}
- reloc = 1;
break;
case PLUS_EXPR:
--- 4219,4224 ----
Index: config/elfos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/elfos.h,v
retrieving revision 1.36
diff -c -3 -p -r1.36 elfos.h
*** elfos.h 2001/11/11 05:56:38 1.36
--- elfos.h 2001/11/19 14:53:17
*************** const_section () \
*** 363,370 ****
/* A C statement or statements to switch to the appropriate
section for output of DECL. DECL is either a `VAR_DECL' node
or a constant of some sort. RELOC indicates whether forming
! the initial value of DECL requires link-time relocations. */
#undef SELECT_SECTION
#define SELECT_SECTION(DECL, RELOC, ALIGN) \
{ \
--- 363,386 ----
/* A C statement or statements to switch to the appropriate
section for output of DECL. DECL is either a `VAR_DECL' node
or a constant of some sort. RELOC indicates whether forming
! the initial value of DECL requires link-time relocations.
!
! To optimize loading of shared programs, define following subsections
! of data section by attaching:
+ .rel
+ Section with this string in name contains data that do have
+ relocations, so they get grouped together and dynamic linker
+ will visit fewer pages in memory.
+ .ro
+ Marks data read only otherwise. This is usefull with prelinking
+ as most of relocations won't be dynamically linked and thus
+ stay read only.
+ .local
+ Marks data containing relocations only to local objects. These
+ relocation will get fully resolved by prelinking.
+ */
+
#undef SELECT_SECTION
#define SELECT_SECTION(DECL, RELOC, ALIGN) \
{ \
*************** const_section () \
*** 377,388 ****
} \
else if (TREE_CODE (DECL) == VAR_DECL) \
{ \
! if ((flag_pic && RELOC) \
! || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
|| !DECL_INITIAL (DECL) \
|| (DECL_INITIAL (DECL) != error_mark_node \
&& !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
! data_section (); \
else if (flag_merge_constants < 2) \
/* C and C++ don't allow different variables to share \
the same location. -fmerge-all-constants allows \
--- 393,414 ----
} \
else if (TREE_CODE (DECL) == VAR_DECL) \
{ \
! if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
|| !DECL_INITIAL (DECL) \
|| (DECL_INITIAL (DECL) != error_mark_node \
&& !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
! { \
! if (flag_pic && (RELOC) & 2) \
! named_section (NULL_TREE, ".data.rel", RELOC); \
! else if (flag_pic && (RELOC)) \
! named_section (NULL_TREE, ".data.rel.local", RELOC);\
! else \
! data_section (); \
! } \
! else if (flag_pic && ((RELOC) & 2)) \
! named_section (NULL_TREE, ".data.rel.ro", RELOC); \
! else if (flag_pic && (RELOC)) \
! named_section (NULL_TREE, ".data.rel.ro.local", RELOC); \
else if (flag_merge_constants < 2) \
/* C and C++ don't allow different variables to share \
the same location. -fmerge-all-constants allows \
*************** const_section () \
*** 397,406 ****
} \
else if (TREE_CODE (DECL) == CONSTRUCTOR) \
{ \
! if ((flag_pic && RELOC) \
! || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
|| ! TREE_CONSTANT (DECL)) \
! data_section (); \
else \
const_section (); \
} \
--- 423,442 ----
} \
else if (TREE_CODE (DECL) == CONSTRUCTOR) \
{ \
! if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
|| ! TREE_CONSTANT (DECL)) \
! { \
! if (flag_pic && ((RELOC) & 2)) \
! named_section (NULL_TREE, ".data.rel", RELOC); \
! else if (flag_pic && (RELOC)) \
! named_section (NULL_TREE, ".data.rel.local", RELOC);\
! else \
! data_section (); \
! } \
! else if (flag_pic && ((RELOC) & 2)) \
! named_section (NULL_TREE, ".data.ro.rel", RELOC); \
! else if (flag_pic && (RELOC)) \
! named_section (NULL_TREE, ".data.ro.rel.local", RELOC); \
else \
const_section (); \
} \
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doc/tm.texi,v
retrieving revision 1.69
diff -c -3 -p -r1.69 tm.texi
*** tm.texi 2001/11/10 21:44:52 1.69
--- tm.texi 2001/11/19 14:53:20
*************** A C statement or statements to switch to
*** 5661,5667 ****
output of @var{exp}. You can assume that @var{exp} is either a
@code{VAR_DECL} node or a constant of some sort. @var{reloc}
indicates whether the initial value of @var{exp} requires link-time
! relocations. Select the section by calling @code{text_section} or one
of the alternatives for other sections. @var{align} is the constant
alignment in bits.
--- 5661,5669 ----
output of @var{exp}. You can assume that @var{exp} is either a
@code{VAR_DECL} node or a constant of some sort. @var{reloc}
indicates whether the initial value of @var{exp} requires link-time
! relocations. Bit 1 is set when variable contains local relocations
! only, while bit 2 is set for global relocations.
! Select the section by calling @code{text_section} or one
of the alternatives for other sections. @var{align} is the constant
alignment in bits.