* Re: [patches] Re: KDE a gcc
2001-11-02 12:23 ` [patches] " Jan Hubicka
@ 2001-11-12 12:11 ` Jan Hubicka
2001-11-13 4:26 ` Jan Hubicka
` (2 subsequent siblings)
3 siblings, 0 replies; 28+ messages in thread
From: Jan Hubicka @ 2001-11-12 12:11 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Lubos Lunak, rth, Jakub Jelinek, gcc-patches, patches
> Hi,
> this patch implements idea described in:
> > http://dforce.sh.cvut.cz/~seli/en/linking2/#data_segment
>
> basically in KDE/QT applications there is lots of pregenerated data that is
> read only, but in PIC compilation it isn't because of dynamic linking. This
> code is intermixed with other readwrite data then. With prelinking this is a
> waste, as the pregenereated data is really readonly so it should be put
> together and without it is waste too, as dynamic linker needs to COW much more
> pages.
>
> This patch adds two new sections. .data.rel is used for read/write data that
> contains relocations (so it will be COWed on startup in case no prelinking is
> done) and .data.rel.ro contains read/only data with relocations that are
> read-only for prelinking and COWed on startup.
>
> Lubos measured about 60Kb saving on simple QT application requiring about 500Kb
> resources with the prelinking. He estimates savings for KDE application to
> about 200Kb. I made simple test with sartup time on the c++ library from
> crystal space w/o prelinking and got about 6% savings in startup time too.
>
> Note that I am not quite sure whether .data.rel / .data.rel.ro are handled as
> .data subsections on all systems. The patch uses the named sections by
> default, but allows to define new opcodes for that too, hope it is flexible
> enought and will not bring considerable compatibility issues.
>
> Honza
Oops, forgot the patch :)
Bootstrapped/regtested i686
Wed Oct 31 17:44:53 CET 2001 Jan Hubicka <jh@susue.cz>
* 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.
* elfos.h (SELECT_SECTION): Use data_rel_section
and data_rel_ro_section for relocatable insns.
* tm.texi (DATA_REL_SECTION_OP, DATA_REL_RO_SECTION_OP):
document.
Index: output.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/output.h,v
retrieving revision 1.87
diff -c -3 -p -r1.87 output.h
*** output.h 2001/11/04 02:47:36 1.87
--- output.h 2001/11/12 14:42:05
*************** extern void text_section PARAMS ((void)
*** 156,161 ****
--- 156,174 ----
/* Tell assembler to switch to data section. */
extern void data_section PARAMS ((void));
+ /* Tell assembler to switch to data_rel section.
+ This section contains data that needs dynamic linking.
+ If there is no dedicated section for this purpose, data
+ section is used. */
+
+ extern void data_rel_section PARAMS ((void));
+
+ /* Like data_rel_section, but data_rel_ro section is used
+ for data needing dynamic linking but read only otherwise.
+ These data are read only with prelinking. */
+
+ extern void data_rel_ro_section PARAMS ((void));
+
/* Tell assembler to make sure its in the data section. */
extern void force_data_section PARAMS ((void));
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/12 14:42:06
*************** static void const_str_htab_del PARAMS (
*** 193,199 ****
static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
static void resolve_unique_section PARAMS ((tree, int));
\f
! static enum in_section { no_section, in_text, in_data, in_named
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
--- 193,200 ----
static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
static void resolve_unique_section PARAMS ((tree, int));
\f
! static enum in_section { no_section, in_text, in_data, in_named, in_data_rel,
! in_data_rel_ro
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
*************** data_section ()
*** 271,276 ****
--- 272,334 ----
in_section = in_data;
}
}
+
+ /* Tell assembler to switch to data_rel section.
+ This section contains data that needs dynamic linking.
+ If there is no dedicated section for this purpose, data
+ section is used. */
+
+ void
+ data_rel_section ()
+ {
+ if (in_section == in_data_rel)
+ ;
+ else if (flag_shared_data || !flag_pic)
+ data_section ();
+ #ifdef DATA_REL_SECTION_ASM_OP
+ else
+ {
+ fprintf (asm_out_file, "%s\n", DATA_REL_SECTION_ASM_OP);
+ in_section = in_data_rel;
+ }
+ #else
+ else if (targetm.have_named_sections)
+ {
+ named_section (NULL_TREE, ".data.rel", 0);
+ in_section = in_data_rel;
+ }
+ else
+ data_section ();
+ #endif
+ }
+
+ /* Like data_rel_section, but data_rel_ro section is used
+ for data needing dynamic linking but read only otherwise.
+ These data are read only with prelinking. */
+
+ void
+ data_rel_ro_section ()
+ {
+ if (in_section == in_data_rel_ro)
+ ;
+ else if (!flag_pic)
+ readonly_data_section ();
+ #ifdef DATA_REL_RO_SECTION_ASM_OP
+ else
+ {
+ fprintf (asm_out_file, "%s\n", DATA_REL_RO_SECTION_ASM_OP);
+ in_section = in_data_rel_ro;
+ }
+ #else
+ else if (targetm.have_named_sections)
+ {
+ named_section (NULL_TREE, ".data.rel.ro", 0);
+ in_section = in_data_rel_ro;
+ }
+ else
+ data_rel_section ();
+ #endif
+ }
/* Tell assembler to ALWAYS switch to data section, in case
it's not sure where it is. */
*************** default_exception_section ()
*** 614,620 ****
if (targetm.have_named_sections)
named_section (NULL_TREE, ".gcc_except_table", 0);
else if (flag_pic)
! data_section ();
else
readonly_data_section ();
}
--- 672,678 ----
if (targetm.have_named_sections)
named_section (NULL_TREE, ".gcc_except_table", 0);
else if (flag_pic)
! data_rel_ro_section ();
else
readonly_data_section ();
}
*************** output_constant_def_contents (exp, reloc
*** 3454,3462 ****
#ifdef SELECT_SECTION
SELECT_SECTION (exp, reloc, align);
#else
! if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
! || (flag_pic && reloc))
data_section ();
else
readonly_data_section ();
#endif
--- 3512,3521 ----
#ifdef SELECT_SECTION
SELECT_SECTION (exp, reloc, align);
#else
! if ((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
data_section ();
+ else if (flag_pic && reloc)
+ data_rel_ro_section ();
else
readonly_data_section ();
#endif
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/12 14:42:07
*************** 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 \
--- 377,394 ----
} \
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) \
! data_rel_section (); \
! else \
! data_section (); \
! } \
! else if (flag_pic && RELOC) \
! data_rel_ro_section (); \
else if (flag_merge_constants < 2) \
/* C and C++ don't allow different variables to share \
the same location. -fmerge-all-constants allows \
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/12 14:42:09
*************** A C expression whose value is a string,
*** 5579,5584 ****
--- 5579,5600 ----
assembler operation to identify the following data as writable initialized
data. Normally @code{"\t.data"} is right.
+ @findex DATA_REL_SECTION_ASM_OP
+ @item DATA_REL_SECTION_ASM_OP
+ A C expression whose value is a string, including spacing, containing the
+ assembler operation to identify the following data as writable initialized
+ data that do need dynamic linking.
+ Used only in PIC compilation and if not present, data section is used
+ instead.
+
+ @findex DATA_REL_RO_SECTION_ASM_OP
+ @item DATA_REL_RO_SECTION_ASM_OP
+ A C expression whose value is a string, including spacing, containing the
+ assembler operation to identify the following data as read only initialized
+ data that do need dynamic linking.
+ Used only in PIC compilation and if not present, data section is used
+ instead.
+
@findex SHARED_SECTION_ASM_OP
@item SHARED_SECTION_ASM_OP
If defined, a C expression whose value is a string, including spacing,
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [patches] Re: KDE a gcc
2001-11-02 12:23 ` [patches] " Jan Hubicka
2001-11-12 12:11 ` Jan Hubicka
@ 2001-11-13 4:26 ` Jan Hubicka
[not found] ` <20011112092319.A15349@redhat.com>
2001-11-13 15:03 ` Jan Hubicka
3 siblings, 0 replies; 28+ messages in thread
From: Jan Hubicka @ 2001-11-13 4:26 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Lubos Lunak, rth, Jakub Jelinek, gcc-patches, patches
> Hi,
> this patch implements idea described in:
> > http://dforce.sh.cvut.cz/~seli/en/linking2/#data_segment
>
> basically in KDE/QT applications there is lots of pregenerated data that is
> read only, but in PIC compilation it isn't because of dynamic linking. This
> code is intermixed with other readwrite data then. With prelinking this is a
> waste, as the pregenereated data is really readonly so it should be put
> together and without it is waste too, as dynamic linker needs to COW much more
> pages.
>
> This patch adds two new sections. .data.rel is used for read/write data that
> contains relocations (so it will be COWed on startup in case no prelinking is
> done) and .data.rel.ro contains read/only data with relocations that are
> read-only for prelinking and COWed on startup.
>
> Lubos measured about 60Kb saving on simple QT application requiring about 500Kb
> resources with the prelinking. He estimates savings for KDE application to
> about 200Kb. I made simple test with sartup time on the c++ library from
> crystal space w/o prelinking and got about 6% savings in startup time too.
>
> Note that I am not quite sure whether .data.rel / .data.rel.ro are handled as
> .data subsections on all systems. The patch uses the named sections by
> default, but allows to define new opcodes for that too, hope it is flexible
> enought and will not bring considerable compatibility issues.
>
> Honza
Oops, forgot the patch :)
Bootstrapped/regtested i686
Wed Oct 31 17:44:53 CET 2001 Jan Hubicka <jh@susue.cz>
* 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.
* elfos.h (SELECT_SECTION): Use data_rel_section
and data_rel_ro_section for relocatable insns.
* tm.texi (DATA_REL_SECTION_OP, DATA_REL_RO_SECTION_OP):
document.
Index: output.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/output.h,v
retrieving revision 1.87
diff -c -3 -p -r1.87 output.h
*** output.h 2001/11/04 02:47:36 1.87
--- output.h 2001/11/12 14:42:05
*************** extern void text_section PARAMS ((void)
*** 156,161 ****
--- 156,174 ----
/* Tell assembler to switch to data section. */
extern void data_section PARAMS ((void));
+ /* Tell assembler to switch to data_rel section.
+ This section contains data that needs dynamic linking.
+ If there is no dedicated section for this purpose, data
+ section is used. */
+
+ extern void data_rel_section PARAMS ((void));
+
+ /* Like data_rel_section, but data_rel_ro section is used
+ for data needing dynamic linking but read only otherwise.
+ These data are read only with prelinking. */
+
+ extern void data_rel_ro_section PARAMS ((void));
+
/* Tell assembler to make sure its in the data section. */
extern void force_data_section PARAMS ((void));
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/12 14:42:06
*************** static void const_str_htab_del PARAMS (
*** 193,199 ****
static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
static void resolve_unique_section PARAMS ((tree, int));
\f
! static enum in_section { no_section, in_text, in_data, in_named
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
--- 193,200 ----
static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
static void resolve_unique_section PARAMS ((tree, int));
\f
! static enum in_section { no_section, in_text, in_data, in_named, in_data_rel,
! in_data_rel_ro
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
*************** data_section ()
*** 271,276 ****
--- 272,334 ----
in_section = in_data;
}
}
+
+ /* Tell assembler to switch to data_rel section.
+ This section contains data that needs dynamic linking.
+ If there is no dedicated section for this purpose, data
+ section is used. */
+
+ void
+ data_rel_section ()
+ {
+ if (in_section == in_data_rel)
+ ;
+ else if (flag_shared_data || !flag_pic)
+ data_section ();
+ #ifdef DATA_REL_SECTION_ASM_OP
+ else
+ {
+ fprintf (asm_out_file, "%s\n", DATA_REL_SECTION_ASM_OP);
+ in_section = in_data_rel;
+ }
+ #else
+ else if (targetm.have_named_sections)
+ {
+ named_section (NULL_TREE, ".data.rel", 0);
+ in_section = in_data_rel;
+ }
+ else
+ data_section ();
+ #endif
+ }
+
+ /* Like data_rel_section, but data_rel_ro section is used
+ for data needing dynamic linking but read only otherwise.
+ These data are read only with prelinking. */
+
+ void
+ data_rel_ro_section ()
+ {
+ if (in_section == in_data_rel_ro)
+ ;
+ else if (!flag_pic)
+ readonly_data_section ();
+ #ifdef DATA_REL_RO_SECTION_ASM_OP
+ else
+ {
+ fprintf (asm_out_file, "%s\n", DATA_REL_RO_SECTION_ASM_OP);
+ in_section = in_data_rel_ro;
+ }
+ #else
+ else if (targetm.have_named_sections)
+ {
+ named_section (NULL_TREE, ".data.rel.ro", 0);
+ in_section = in_data_rel_ro;
+ }
+ else
+ data_rel_section ();
+ #endif
+ }
/* Tell assembler to ALWAYS switch to data section, in case
it's not sure where it is. */
*************** default_exception_section ()
*** 614,620 ****
if (targetm.have_named_sections)
named_section (NULL_TREE, ".gcc_except_table", 0);
else if (flag_pic)
! data_section ();
else
readonly_data_section ();
}
--- 672,678 ----
if (targetm.have_named_sections)
named_section (NULL_TREE, ".gcc_except_table", 0);
else if (flag_pic)
! data_rel_ro_section ();
else
readonly_data_section ();
}
*************** output_constant_def_contents (exp, reloc
*** 3454,3462 ****
#ifdef SELECT_SECTION
SELECT_SECTION (exp, reloc, align);
#else
! if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
! || (flag_pic && reloc))
data_section ();
else
readonly_data_section ();
#endif
--- 3512,3521 ----
#ifdef SELECT_SECTION
SELECT_SECTION (exp, reloc, align);
#else
! if ((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
data_section ();
+ else if (flag_pic && reloc)
+ data_rel_ro_section ();
else
readonly_data_section ();
#endif
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/12 14:42:07
*************** 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 \
--- 377,394 ----
} \
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) \
! data_rel_section (); \
! else \
! data_section (); \
! } \
! else if (flag_pic && RELOC) \
! data_rel_ro_section (); \
else if (flag_merge_constants < 2) \
/* C and C++ don't allow different variables to share \
the same location. -fmerge-all-constants allows \
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/12 14:42:09
*************** A C expression whose value is a string,
*** 5579,5584 ****
--- 5579,5600 ----
assembler operation to identify the following data as writable initialized
data. Normally @code{"\t.data"} is right.
+ @findex DATA_REL_SECTION_ASM_OP
+ @item DATA_REL_SECTION_ASM_OP
+ A C expression whose value is a string, including spacing, containing the
+ assembler operation to identify the following data as writable initialized
+ data that do need dynamic linking.
+ Used only in PIC compilation and if not present, data section is used
+ instead.
+
+ @findex DATA_REL_RO_SECTION_ASM_OP
+ @item DATA_REL_RO_SECTION_ASM_OP
+ A C expression whose value is a string, including spacing, containing the
+ assembler operation to identify the following data as read only initialized
+ data that do need dynamic linking.
+ Used only in PIC compilation and if not present, data section is used
+ instead.
+
@findex SHARED_SECTION_ASM_OP
@item SHARED_SECTION_ASM_OP
If defined, a C expression whose value is a string, including spacing,
^ permalink raw reply [flat|nested] 28+ messages in thread
[parent not found: <20011112092319.A15349@redhat.com>]
* Re: [patches] Re: KDE a gcc
[not found] ` <20011112092319.A15349@redhat.com>
@ 2001-11-13 15:03 ` Jan Hubicka
2001-11-13 15:03 ` Jakub Jelinek
0 siblings, 1 reply; 28+ messages in thread
From: Jan Hubicka @ 2001-11-13 15:03 UTC (permalink / raw)
To: Richard Henderson, Jan Hubicka, Lubos Lunak, Jakub Jelinek,
gcc-patches, patches
> 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.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [patches] Re: KDE a gcc
2001-11-13 15:03 ` Jan Hubicka
@ 2001-11-13 15:03 ` Jakub Jelinek
2001-11-13 15:03 ` Jakub Jelinek
0 siblings, 1 reply; 28+ messages in thread
From: Jakub Jelinek @ 2001-11-13 15:03 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Richard Henderson, Lubos Lunak, gcc-patches, patches
On Mon, Nov 19, 2001 at 03:57:54PM +0100, Jan Hubicka wrote:
> 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.
> ! 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_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); \
You should keep the same order of suffixes all the time.
So IMHO the latter should be .data.rel.ro and .data.rel.ro.local.
Jakub
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [patches] Re: KDE a gcc
2001-11-13 15:03 ` Jakub Jelinek
@ 2001-11-13 15:03 ` Jakub Jelinek
2001-11-13 15:03 ` KDE and gcc take III Jan Hubicka
2001-11-22 1:32 ` [patches] Re: KDE a gcc Jakub Jelinek
0 siblings, 2 replies; 28+ messages in thread
From: Jakub Jelinek @ 2001-11-13 15:03 UTC (permalink / raw)
To: jh; +Cc: Richard Henderson, Lubos Lunak, gcc-patches, patches
On Wed, Nov 21, 2001 at 10:45:27AM -0500, Jakub Jelinek wrote:
> On Mon, Nov 19, 2001 at 03:57:54PM +0100, Jan Hubicka wrote:
> > 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.
>
> > ! 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_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); \
>
> You should keep the same order of suffixes all the time.
> So IMHO the latter should be .data.rel.ro and .data.rel.ro.local.
And another question is whether it shouldn't be done for .gnu.linkonce.d
data similarly (ie. have
.gnu.linkonce.d.rel.*, .gnu.linkonce.d.rel.ro.*, .gnu.linkonce.d.rel.local.*
and .gnu.linkonce.d.rel.ro.local.*).
Jakub
^ permalink raw reply [flat|nested] 28+ messages in thread
* KDE and gcc take III
2001-11-13 15:03 ` Jakub Jelinek
@ 2001-11-13 15:03 ` Jan Hubicka
2001-11-14 7:28 ` Richard Henderson
2001-11-22 5:06 ` Jan Hubicka
2001-11-22 1:32 ` [patches] Re: KDE a gcc Jakub Jelinek
1 sibling, 2 replies; 28+ messages in thread
From: Jan Hubicka @ 2001-11-13 15:03 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: jh, Richard Henderson, Lubos Lunak, gcc-patches, patches
> On Wed, Nov 21, 2001 at 10:45:27AM -0500, Jakub Jelinek wrote:
> > On Mon, Nov 19, 2001 at 03:57:54PM +0100, Jan Hubicka wrote:
> > > 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.
> >
> > > ! 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_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); \
> >
> > You should keep the same order of suffixes all the time.
> > So IMHO the latter should be .data.rel.ro and .data.rel.ro.local.
True, I've missed that. Thanks!
>
> And another question is whether it shouldn't be done for .gnu.linkonce.d
> data similarly (ie. have
> .gnu.linkonce.d.rel.*, .gnu.linkonce.d.rel.ro.*, .gnu.linkonce.d.rel.local.*
> and .gnu.linkonce.d.rel.ro.local.*).
OK, I can do that as followup patch, to have this issue settled down. OK?
Honza
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.rel.ro", RELOC); \
! else if (flag_pic && (RELOC)) \
! named_section (NULL_TREE, ".data.rel.ro.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.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: KDE and gcc take III
2001-11-13 15:03 ` KDE and gcc take III Jan Hubicka
@ 2001-11-14 7:28 ` Richard Henderson
2001-11-14 8:35 ` Jan Hubicka
2001-11-24 11:10 ` Richard Henderson
2001-11-22 5:06 ` Jan Hubicka
1 sibling, 2 replies; 28+ messages in thread
From: Richard Henderson @ 2001-11-14 7:28 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Jakub Jelinek, Lubos Lunak, gcc-patches, patches
On Thu, Nov 22, 2001 at 02:06:33PM +0100, Jan Hubicka wrote:
> ! if (TREE_CODE (constant) == CONSTRUCTOR)
> ! reloc = 1;
Overriding previous data? Surely not. Can't I reference global
data from a constructor?
> ! if (flag_pic && (RELOC) & 2) \
Parenthesis.
> else if (TREE_CODE (DECL) == CONSTRUCTOR) \
> { \
> ! if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
> || ! TREE_CONSTANT (DECL)) \
Remove the test for TREE_READONLY for CONSTRUCTOR.
r~
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: KDE and gcc take III
2001-11-14 7:28 ` Richard Henderson
@ 2001-11-14 8:35 ` Jan Hubicka
2001-11-14 11:17 ` Richard Henderson
2001-11-24 11:20 ` Jan Hubicka
2001-11-24 11:10 ` Richard Henderson
1 sibling, 2 replies; 28+ messages in thread
From: Jan Hubicka @ 2001-11-14 8:35 UTC (permalink / raw)
To: Richard Henderson, Jan Hubicka, Jakub Jelinek, Lubos Lunak,
gcc-patches, patches
> On Thu, Nov 22, 2001 at 02:06:33PM +0100, Jan Hubicka wrote:
> > ! if (TREE_CODE (constant) == CONSTRUCTOR)
> > ! reloc = 1;
>
> Overriding previous data? Surely not. Can't I reference global
Probably not needed anymore, but aren't we speaking about reference to
the constructor and not constructor itself?
Honza
> data from a constructor?
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: KDE and gcc take III
2001-11-14 8:35 ` Jan Hubicka
@ 2001-11-14 11:17 ` Richard Henderson
2001-11-24 12:26 ` Richard Henderson
2001-11-24 11:20 ` Jan Hubicka
1 sibling, 1 reply; 28+ messages in thread
From: Richard Henderson @ 2001-11-14 11:17 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Jakub Jelinek, Lubos Lunak, gcc-patches, patches
On Sat, Nov 24, 2001 at 08:20:41PM +0100, Jan Hubicka wrote:
> Probably not needed anymore, but aren't we speaking about reference to
> the constructor and not constructor itself?
I don't know. But surely a constructor itself would not
be marked TREE_PUBLIC, so why the extra test?
r~
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: KDE and gcc take III
2001-11-14 11:17 ` Richard Henderson
@ 2001-11-24 12:26 ` Richard Henderson
0 siblings, 0 replies; 28+ messages in thread
From: Richard Henderson @ 2001-11-24 12:26 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Jakub Jelinek, Lubos Lunak, gcc-patches, patches
On Sat, Nov 24, 2001 at 08:20:41PM +0100, Jan Hubicka wrote:
> Probably not needed anymore, but aren't we speaking about reference to
> the constructor and not constructor itself?
I don't know. But surely a constructor itself would not
be marked TREE_PUBLIC, so why the extra test?
r~
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: KDE and gcc take III
2001-11-14 8:35 ` Jan Hubicka
2001-11-14 11:17 ` Richard Henderson
@ 2001-11-24 11:20 ` Jan Hubicka
1 sibling, 0 replies; 28+ messages in thread
From: Jan Hubicka @ 2001-11-24 11:20 UTC (permalink / raw)
To: Richard Henderson, Jan Hubicka, Jakub Jelinek, Lubos Lunak,
gcc-patches, patches
> On Thu, Nov 22, 2001 at 02:06:33PM +0100, Jan Hubicka wrote:
> > ! if (TREE_CODE (constant) == CONSTRUCTOR)
> > ! reloc = 1;
>
> Overriding previous data? Surely not. Can't I reference global
Probably not needed anymore, but aren't we speaking about reference to
the constructor and not constructor itself?
Honza
> data from a constructor?
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: KDE and gcc take III
2001-11-14 7:28 ` Richard Henderson
2001-11-14 8:35 ` Jan Hubicka
@ 2001-11-24 11:10 ` Richard Henderson
1 sibling, 0 replies; 28+ messages in thread
From: Richard Henderson @ 2001-11-24 11:10 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Jakub Jelinek, Lubos Lunak, gcc-patches, patches
On Thu, Nov 22, 2001 at 02:06:33PM +0100, Jan Hubicka wrote:
> ! if (TREE_CODE (constant) == CONSTRUCTOR)
> ! reloc = 1;
Overriding previous data? Surely not. Can't I reference global
data from a constructor?
> ! if (flag_pic && (RELOC) & 2) \
Parenthesis.
> else if (TREE_CODE (DECL) == CONSTRUCTOR) \
> { \
> ! if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
> || ! TREE_CONSTANT (DECL)) \
Remove the test for TREE_READONLY for CONSTRUCTOR.
r~
^ permalink raw reply [flat|nested] 28+ messages in thread
* KDE and gcc take III
2001-11-13 15:03 ` KDE and gcc take III Jan Hubicka
2001-11-14 7:28 ` Richard Henderson
@ 2001-11-22 5:06 ` Jan Hubicka
1 sibling, 0 replies; 28+ messages in thread
From: Jan Hubicka @ 2001-11-22 5:06 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: jh, Richard Henderson, Lubos Lunak, gcc-patches, patches
> On Wed, Nov 21, 2001 at 10:45:27AM -0500, Jakub Jelinek wrote:
> > On Mon, Nov 19, 2001 at 03:57:54PM +0100, Jan Hubicka wrote:
> > > 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.
> >
> > > ! 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_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); \
> >
> > You should keep the same order of suffixes all the time.
> > So IMHO the latter should be .data.rel.ro and .data.rel.ro.local.
True, I've missed that. Thanks!
>
> And another question is whether it shouldn't be done for .gnu.linkonce.d
> data similarly (ie. have
> .gnu.linkonce.d.rel.*, .gnu.linkonce.d.rel.ro.*, .gnu.linkonce.d.rel.local.*
> and .gnu.linkonce.d.rel.ro.local.*).
OK, I can do that as followup patch, to have this issue settled down. OK?
Honza
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.rel.ro", RELOC); \
! else if (flag_pic && (RELOC)) \
! named_section (NULL_TREE, ".data.rel.ro.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.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [patches] Re: KDE a gcc
2001-11-13 15:03 ` Jakub Jelinek
2001-11-13 15:03 ` KDE and gcc take III Jan Hubicka
@ 2001-11-22 1:32 ` Jakub Jelinek
1 sibling, 0 replies; 28+ messages in thread
From: Jakub Jelinek @ 2001-11-22 1:32 UTC (permalink / raw)
To: jh; +Cc: Richard Henderson, Lubos Lunak, gcc-patches, patches
On Wed, Nov 21, 2001 at 10:45:27AM -0500, Jakub Jelinek wrote:
> On Mon, Nov 19, 2001 at 03:57:54PM +0100, Jan Hubicka wrote:
> > 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.
>
> > ! 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_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); \
>
> You should keep the same order of suffixes all the time.
> So IMHO the latter should be .data.rel.ro and .data.rel.ro.local.
And another question is whether it shouldn't be done for .gnu.linkonce.d
data similarly (ie. have
.gnu.linkonce.d.rel.*, .gnu.linkonce.d.rel.ro.*, .gnu.linkonce.d.rel.local.*
and .gnu.linkonce.d.rel.ro.local.*).
Jakub
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [patches] Re: KDE a gcc
2001-11-02 12:23 ` [patches] " Jan Hubicka
` (2 preceding siblings ...)
[not found] ` <20011112092319.A15349@redhat.com>
@ 2001-11-13 15:03 ` Jan Hubicka
3 siblings, 0 replies; 28+ messages in thread
From: Jan Hubicka @ 2001-11-13 15:03 UTC (permalink / raw)
To: Jan Hubicka; +Cc: Lubos Lunak, rth, Jakub Jelinek, gcc-patches, patches
> Hi,
> this patch implements idea described in:
> > http://dforce.sh.cvut.cz/~seli/en/linking2/#data_segment
>
> basically in KDE/QT applications there is lots of pregenerated data that is
> read only, but in PIC compilation it isn't because of dynamic linking. This
> code is intermixed with other readwrite data then. With prelinking this is a
> waste, as the pregenereated data is really readonly so it should be put
> together and without it is waste too, as dynamic linker needs to COW much more
> pages.
>
> This patch adds two new sections. .data.rel is used for read/write data that
> contains relocations (so it will be COWed on startup in case no prelinking is
> done) and .data.rel.ro contains read/only data with relocations that are
> read-only for prelinking and COWed on startup.
>
> Lubos measured about 60Kb saving on simple QT application requiring about 500Kb
> resources with the prelinking. He estimates savings for KDE application to
> about 200Kb. I made simple test with sartup time on the c++ library from
> crystal space w/o prelinking and got about 6% savings in startup time too.
>
> Note that I am not quite sure whether .data.rel / .data.rel.ro are handled as
> .data subsections on all systems. The patch uses the named sections by
> default, but allows to define new opcodes for that too, hope it is flexible
> enought and will not bring considerable compatibility issues.
>
> Honza
Oops, forgot the patch :)
Bootstrapped/regtested i686
Wed Oct 31 17:44:53 CET 2001 Jan Hubicka <jh@susue.cz>
* 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.
* elfos.h (SELECT_SECTION): Use data_rel_section
and data_rel_ro_section for relocatable insns.
* tm.texi (DATA_REL_SECTION_OP, DATA_REL_RO_SECTION_OP):
document.
Index: output.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/output.h,v
retrieving revision 1.87
diff -c -3 -p -r1.87 output.h
*** output.h 2001/11/04 02:47:36 1.87
--- output.h 2001/11/12 14:42:05
*************** extern void text_section PARAMS ((void)
*** 156,161 ****
--- 156,174 ----
/* Tell assembler to switch to data section. */
extern void data_section PARAMS ((void));
+ /* Tell assembler to switch to data_rel section.
+ This section contains data that needs dynamic linking.
+ If there is no dedicated section for this purpose, data
+ section is used. */
+
+ extern void data_rel_section PARAMS ((void));
+
+ /* Like data_rel_section, but data_rel_ro section is used
+ for data needing dynamic linking but read only otherwise.
+ These data are read only with prelinking. */
+
+ extern void data_rel_ro_section PARAMS ((void));
+
/* Tell assembler to make sure its in the data section. */
extern void force_data_section PARAMS ((void));
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/12 14:42:06
*************** static void const_str_htab_del PARAMS (
*** 193,199 ****
static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
static void resolve_unique_section PARAMS ((tree, int));
\f
! static enum in_section { no_section, in_text, in_data, in_named
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
--- 193,200 ----
static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
static void resolve_unique_section PARAMS ((tree, int));
\f
! static enum in_section { no_section, in_text, in_data, in_named, in_data_rel,
! in_data_rel_ro
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
*************** data_section ()
*** 271,276 ****
--- 272,334 ----
in_section = in_data;
}
}
+
+ /* Tell assembler to switch to data_rel section.
+ This section contains data that needs dynamic linking.
+ If there is no dedicated section for this purpose, data
+ section is used. */
+
+ void
+ data_rel_section ()
+ {
+ if (in_section == in_data_rel)
+ ;
+ else if (flag_shared_data || !flag_pic)
+ data_section ();
+ #ifdef DATA_REL_SECTION_ASM_OP
+ else
+ {
+ fprintf (asm_out_file, "%s\n", DATA_REL_SECTION_ASM_OP);
+ in_section = in_data_rel;
+ }
+ #else
+ else if (targetm.have_named_sections)
+ {
+ named_section (NULL_TREE, ".data.rel", 0);
+ in_section = in_data_rel;
+ }
+ else
+ data_section ();
+ #endif
+ }
+
+ /* Like data_rel_section, but data_rel_ro section is used
+ for data needing dynamic linking but read only otherwise.
+ These data are read only with prelinking. */
+
+ void
+ data_rel_ro_section ()
+ {
+ if (in_section == in_data_rel_ro)
+ ;
+ else if (!flag_pic)
+ readonly_data_section ();
+ #ifdef DATA_REL_RO_SECTION_ASM_OP
+ else
+ {
+ fprintf (asm_out_file, "%s\n", DATA_REL_RO_SECTION_ASM_OP);
+ in_section = in_data_rel_ro;
+ }
+ #else
+ else if (targetm.have_named_sections)
+ {
+ named_section (NULL_TREE, ".data.rel.ro", 0);
+ in_section = in_data_rel_ro;
+ }
+ else
+ data_rel_section ();
+ #endif
+ }
/* Tell assembler to ALWAYS switch to data section, in case
it's not sure where it is. */
*************** default_exception_section ()
*** 614,620 ****
if (targetm.have_named_sections)
named_section (NULL_TREE, ".gcc_except_table", 0);
else if (flag_pic)
! data_section ();
else
readonly_data_section ();
}
--- 672,678 ----
if (targetm.have_named_sections)
named_section (NULL_TREE, ".gcc_except_table", 0);
else if (flag_pic)
! data_rel_ro_section ();
else
readonly_data_section ();
}
*************** output_constant_def_contents (exp, reloc
*** 3454,3462 ****
#ifdef SELECT_SECTION
SELECT_SECTION (exp, reloc, align);
#else
! if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
! || (flag_pic && reloc))
data_section ();
else
readonly_data_section ();
#endif
--- 3512,3521 ----
#ifdef SELECT_SECTION
SELECT_SECTION (exp, reloc, align);
#else
! if ((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
data_section ();
+ else if (flag_pic && reloc)
+ data_rel_ro_section ();
else
readonly_data_section ();
#endif
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/12 14:42:07
*************** 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 \
--- 377,394 ----
} \
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) \
! data_rel_section (); \
! else \
! data_section (); \
! } \
! else if (flag_pic && RELOC) \
! data_rel_ro_section (); \
else if (flag_merge_constants < 2) \
/* C and C++ don't allow different variables to share \
the same location. -fmerge-all-constants allows \
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/12 14:42:09
*************** A C expression whose value is a string,
*** 5579,5584 ****
--- 5579,5600 ----
assembler operation to identify the following data as writable initialized
data. Normally @code{"\t.data"} is right.
+ @findex DATA_REL_SECTION_ASM_OP
+ @item DATA_REL_SECTION_ASM_OP
+ A C expression whose value is a string, including spacing, containing the
+ assembler operation to identify the following data as writable initialized
+ data that do need dynamic linking.
+ Used only in PIC compilation and if not present, data section is used
+ instead.
+
+ @findex DATA_REL_RO_SECTION_ASM_OP
+ @item DATA_REL_RO_SECTION_ASM_OP
+ A C expression whose value is a string, including spacing, containing the
+ assembler operation to identify the following data as read only initialized
+ data that do need dynamic linking.
+ Used only in PIC compilation and if not present, data section is used
+ instead.
+
@findex SHARED_SECTION_ASM_OP
@item SHARED_SECTION_ASM_OP
If defined, a C expression whose value is a string, including spacing,
^ permalink raw reply [flat|nested] 28+ messages in thread