* RFC: Speeding up libstdc++.so with --dynamic-list-data
@ 2007-01-09 2:26 H. J. Lu
2007-01-09 4:10 ` Andrew Pinski
2007-01-09 13:38 ` Andrew Haley
0 siblings, 2 replies; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 2:26 UTC (permalink / raw)
To: binutils; +Cc: gcc
[-- Attachment #1: Type: text/plain, Size: 446 bytes --]
I am enclosing a patch to implement a new linker swicth,
--dynamic-list-data. It is -Bsymbolic for function symbols only.
I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
and Linux/ia64. There are only a few regressions. The function calls
within the new resulting DSOs will bind locally. It speeds up
the enclosed C++ testcase by
1. 23% on ia64.
2. 6% on ia32.
3. 3% on x86-64.
Should we consider such optimization?
H.J.
[-- Attachment #2: binutils-dynamic-data-3.patch --]
[-- Type: text/plain, Size: 7955 bytes --]
bfd/
2007-01-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* elf-bfd.h (bfd_elf_link_mark_dynamic_symbol): Add an
argument, Elf_Internal_Sym *.
* elflink.c (bfd_elf_link_mark_dynamic_symbol): Mark a data
symbol dynamic if info->dynamic_data is TRUE.
(bfd_elf_record_link_assignment): Updated call to
bfd_elf_record_link_assignment.
(_bfd_elf_merge_symbol): Likewise. Always call
bfd_elf_link_mark_dynamic_symbol.
include/
2007-01-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* bfdlink.h (bfd_link_info): Rename dynamic to dynamic_list.
Add dynamic and dynamic_data.
ld/
2007-01-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* ldlang.c (lang_process): Change link_info.dynamic to
link_info.dynamic_list.
(lang_append_dynamic_list): Likewise.
* ldmain.c (main): Likewise. Initialize link_info.dynamic and
link_info.dynamic_data to FALSE.
* lexsup.c (option_values): Add OPTION_DYNAMIC_LIST_DATA.
(ld_options): --dynamic-list-data.
(parse_args): Change link_info.dynamic to
link_info.dynamic_list. Set link_info.dynamic_data to TRUE for
--dynamic-list-data. Set link_info.dynamic to TRUE for
--dynamuc-list*.
--- binutils/bfd/elf-bfd.h.data 2007-01-08 10:05:49.000000000 -0800
+++ binutils/bfd/elf-bfd.h 2007-01-08 10:05:49.000000000 -0800
@@ -1858,7 +1858,8 @@ extern int bfd_elf_link_record_local_dyn
(struct bfd_link_info *, bfd *, long);
extern void bfd_elf_link_mark_dynamic_symbol
- (struct bfd_link_info *, struct elf_link_hash_entry *);
+ (struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *);
extern bfd_boolean _bfd_elf_close_and_cleanup
(bfd *);
--- binutils/bfd/elflink.c.data 2007-01-08 10:05:49.000000000 -0800
+++ binutils/bfd/elflink.c 2007-01-08 17:42:35.000000000 -0800
@@ -454,14 +454,22 @@ bfd_elf_link_record_dynamic_symbol (stru
void
bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *info,
- struct elf_link_hash_entry *h)
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
{
- struct bfd_elf_dynamic_list *d = info->dynamic;
+ struct bfd_elf_dynamic_list *d = info->dynamic_list;
- if (d == NULL || info->relocatable)
+ /* It may be called more than once on the same H. */
+ if(h->dynamic || info->relocatable)
return;
- if ((*d->match) (&d->head, NULL, h->root.root.string))
+ if ((info->dynamic_data
+ && (h->type == STT_OBJECT
+ || (sym != NULL
+ && ELF_ST_TYPE (sym->st_info) == STT_OBJECT)))
+ || (d != NULL
+ && h->root.type == bfd_link_hash_new
+ && (*d->match) (&d->head, NULL, h->root.root.string)))
h->dynamic = 1;
}
@@ -499,7 +507,7 @@ bfd_elf_record_link_assignment (bfd *out
if (h->root.type == bfd_link_hash_new)
{
- bfd_elf_link_mark_dynamic_symbol (info, h);
+ bfd_elf_link_mark_dynamic_symbol (info, h, NULL);
h->non_elf = 0;
}
@@ -906,13 +914,17 @@ _bfd_elf_merge_symbol (bfd *abfd,
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ /* We have to check it for every instance since the first few may be
+ refereences and not all compilers emit symbol type for undefined
+ symbols. */
+ bfd_elf_link_mark_dynamic_symbol (info, h, sym);
+
/* If we just created the symbol, mark it as being an ELF symbol.
Other than that, there is nothing to do--there is no merge issue
with a newly defined symbol--so we just return. */
if (h->root.type == bfd_link_hash_new)
{
- bfd_elf_link_mark_dynamic_symbol (info, h);
h->non_elf = 0;
return TRUE;
}
--- binutils/include/bfdlink.h.data 2006-10-30 15:25:51.000000000 -0800
+++ binutils/include/bfdlink.h 2007-01-08 10:05:49.000000000 -0800
@@ -340,6 +340,13 @@ struct bfd_link_info
caching ELF symbol buffer. */
unsigned int reduce_memory_overheads: 1;
+ /* TRUE if all data symbols should be dynamic. */
+ unsigned int dynamic_data: 1;
+
+ /* TRUE if some symbols have to be dynamic, controlled by
+ --dynamic-list command line options. */
+ unsigned int dynamic: 1;
+
/* What to do with unresolved symbols in an object file.
When producing executables the default is GENERATE_ERROR.
When producing shared libraries the default is IGNORE. The
@@ -440,7 +447,7 @@ struct bfd_link_info
bfd_vma relro_start, relro_end;
/* List of symbols should be dynamic. */
- struct bfd_elf_dynamic_list *dynamic;
+ struct bfd_elf_dynamic_list *dynamic_list;
};
/* This structures holds a set of callback functions. These are
--- binutils/ld/ldlang.c.data 2007-01-08 10:05:49.000000000 -0800
+++ binutils/ld/ldlang.c 2007-01-08 10:05:49.000000000 -0800
@@ -5732,8 +5732,8 @@ void
lang_process (void)
{
/* Finalize dynamic list. */
- if (link_info.dynamic)
- lang_finalize_version_expr_head (&link_info.dynamic->head);
+ if (link_info.dynamic_list)
+ lang_finalize_version_expr_head (&link_info.dynamic_list->head);
current_target = default_target;
@@ -7047,13 +7047,13 @@ lang_add_unique (const char *name)
void
lang_append_dynamic_list (struct bfd_elf_version_expr *dynamic)
{
- if (link_info.dynamic)
+ if (link_info.dynamic_list)
{
struct bfd_elf_version_expr *tail;
for (tail = dynamic; tail->next != NULL; tail = tail->next)
;
- tail->next = link_info.dynamic->head.list;
- link_info.dynamic->head.list = dynamic;
+ tail->next = link_info.dynamic_list->head.list;
+ link_info.dynamic_list->head.list = dynamic;
}
else
{
@@ -7062,7 +7062,7 @@ lang_append_dynamic_list (struct bfd_elf
d = xcalloc (1, sizeof *d);
d->head.list = dynamic;
d->match = lang_vers_match;
- link_info.dynamic = d;
+ link_info.dynamic_list = d;
}
}
--- binutils/ld/ldmain.c.data 2006-10-30 15:25:51.000000000 -0800
+++ binutils/ld/ldmain.c 2007-01-08 10:05:49.000000000 -0800
@@ -318,7 +318,9 @@ main (int argc, char **argv)
link_info.warn_shared_textrel = FALSE;
link_info.gc_sections = FALSE;
link_info.print_gc_sections = FALSE;
- link_info.dynamic = NULL;
+ link_info.dynamic = FALSE;
+ link_info.dynamic_list = NULL;
+ link_info.dynamic_data = FALSE;
link_info.reduce_memory_overheads = FALSE;
config.maxpagesize = 0;
--- binutils/ld/lexsup.c.data 2006-10-30 15:25:51.000000000 -0800
+++ binutils/ld/lexsup.c 2007-01-08 10:05:49.000000000 -0800
@@ -109,6 +109,7 @@ enum option_values
OPTION_VERSION_EXPORTS_SECTION,
OPTION_DYNAMIC_LIST,
OPTION_DYNAMIC_LIST_CPP_TYPEINFO,
+ OPTION_DYNAMIC_LIST_DATA,
OPTION_WARN_COMMON,
OPTION_WARN_CONSTRUCTORS,
OPTION_WARN_FATAL,
@@ -507,6 +508,8 @@ static const struct ld_option ld_options
'\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
{ {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
'\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
+ { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
+ '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
{ {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
'\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
{ {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
@@ -1244,8 +1247,13 @@ parse_args (unsigned argc, char **argv)
.exports sections. */
command_line.version_exports_section = optarg;
break;
+ case OPTION_DYNAMIC_LIST_DATA:
+ link_info.dynamic_data = TRUE;
+ link_info.dynamic = TRUE;
+ break;
case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
lang_append_dynamic_list_cpp_typeinfo ();
+ link_info.dynamic = TRUE;
break;
case OPTION_DYNAMIC_LIST:
/* This option indicates a small script that only specifies
@@ -1260,6 +1268,7 @@ parse_args (unsigned argc, char **argv)
parser_input = input_dynamic_list;
yyparse ();
}
+ link_info.dynamic = TRUE;
break;
case OPTION_WARN_COMMON:
config.warn_common = TRUE;
[-- Attachment #3: set.cc --]
[-- Type: text/plain, Size: 434 bytes --]
#include <set>
#include <cstdio>
#include <cstdlib>
using namespace std;
int
main(int argc, char **argv)
{
int n = argc == 2 ? atoi(argv[1]) : 10000;
set<int> s;
for(int i = 0; i < n; i++)
s.insert(rand());
for(int i = 0; i < 10000; i++){
for(set<int>::iterator it = s.begin(); it != s.end(); ++it){
if(*it < 0) return 1;
}
}
// printf("set size: %d\n", (int)s.size());
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 2:26 RFC: Speeding up libstdc++.so with --dynamic-list-data H. J. Lu
@ 2007-01-09 4:10 ` Andrew Pinski
2007-01-09 4:23 ` H. J. Lu
2007-01-09 13:38 ` Andrew Haley
1 sibling, 1 reply; 15+ messages in thread
From: Andrew Pinski @ 2007-01-09 4:10 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils, gcc
On Mon, 2007-01-08 at 18:25 -0800, H. J. Lu wrote:
> I am enclosing a patch to implement a new linker swicth,
> --dynamic-list-data. It is -Bsymbolic for function symbols only.
> I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> and Linux/ia64. There are only a few regressions. The function calls
> within the new resulting DSOs will bind locally. It speeds up
> the enclosed C++ testcase by
>
> 1. 23% on ia64.
> 2. 6% on ia32.
> 3. 3% on x86-64.
>
> Should we consider such optimization?
The real question is, does this work with operator new?
In that if I a C++ developer provides a seperate operator new (and
delete), does libstdc++ use that one as required by the C++ standard?
Thanks,
Andrew Pinski
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 4:10 ` Andrew Pinski
@ 2007-01-09 4:23 ` H. J. Lu
2007-01-09 14:50 ` H. J. Lu
0 siblings, 1 reply; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 4:23 UTC (permalink / raw)
To: Andrew Pinski; +Cc: binutils, gcc
On Mon, Jan 08, 2007 at 08:09:59PM -0800, Andrew Pinski wrote:
> On Mon, 2007-01-08 at 18:25 -0800, H. J. Lu wrote:
> > I am enclosing a patch to implement a new linker swicth,
> > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > and Linux/ia64. There are only a few regressions. The function calls
> > within the new resulting DSOs will bind locally. It speeds up
> > the enclosed C++ testcase by
> >
> > 1. 23% on ia64.
> > 2. 6% on ia32.
> > 3. 3% on x86-64.
> >
> > Should we consider such optimization?
>
> The real question is, does this work with operator new?
>
> In that if I a C++ developer provides a seperate operator new (and
> delete), does libstdc++ use that one as required by the C++ standard?
These are the regressions I was talking about. I can support them with
a new linker switch. So far, we have
--dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
--dynamic-list FILE Read dynamic list
My current proposal adds
--dynamic-list-data Add data symbols to dynamic list
I can add a new one
--dynamic-list-cpp-new Add C++ new/delete to dynamic list
Then we can build libstdc++ with
--dynamic-list-data --dynamic-list-cpp-new
H.J.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 2:26 RFC: Speeding up libstdc++.so with --dynamic-list-data H. J. Lu
2007-01-09 4:10 ` Andrew Pinski
@ 2007-01-09 13:38 ` Andrew Haley
2007-01-09 13:41 ` H. J. Lu
1 sibling, 1 reply; 15+ messages in thread
From: Andrew Haley @ 2007-01-09 13:38 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils, gcc
H. J. Lu writes:
> I am enclosing a patch to implement a new linker swicth,
> --dynamic-list-data. It is -Bsymbolic for function symbols only.
> I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> and Linux/ia64. There are only a few regressions. The function calls
> within the new resulting DSOs will bind locally. It speeds up
> the enclosed C++ testcase by
>
> 1. 23% on ia64.
> 2. 6% on ia32.
> 3. 3% on x86-64.
>
> Should we consider such optimization?
That's a terrible name for the option. What does it mean?
Andrew.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 13:38 ` Andrew Haley
@ 2007-01-09 13:41 ` H. J. Lu
2007-01-09 13:51 ` Andrew Haley
0 siblings, 1 reply; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 13:41 UTC (permalink / raw)
To: Andrew Haley; +Cc: binutils, gcc
On Tue, Jan 09, 2007 at 01:38:00PM +0000, Andrew Haley wrote:
> H. J. Lu writes:
> > I am enclosing a patch to implement a new linker swicth,
> > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > and Linux/ia64. There are only a few regressions. The function calls
> > within the new resulting DSOs will bind locally. It speeds up
> > the enclosed C++ testcase by
> >
> > 1. 23% on ia64.
> > 2. 6% on ia32.
> > 3. 3% on x86-64.
> >
> > Should we consider such optimization?
>
> That's a terrible name for the option. What does it mean?
It is an extension of the current command line options:
--dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
--dynamic-list FILE Read dynamic list
H.J.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 13:41 ` H. J. Lu
@ 2007-01-09 13:51 ` Andrew Haley
2007-01-09 13:56 ` H. J. Lu
0 siblings, 1 reply; 15+ messages in thread
From: Andrew Haley @ 2007-01-09 13:51 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils, gcc
H. J. Lu writes:
> On Tue, Jan 09, 2007 at 01:38:00PM +0000, Andrew Haley wrote:
> > H. J. Lu writes:
> > > I am enclosing a patch to implement a new linker swicth,
> > > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > > and Linux/ia64. There are only a few regressions. The function calls
> > > within the new resulting DSOs will bind locally. It speeds up
> > > the enclosed C++ testcase by
> > >
> > > 1. 23% on ia64.
> > > 2. 6% on ia32.
> > > 3. 3% on x86-64.
> > >
> > > Should we consider such optimization?
> >
> > That's a terrible name for the option. What does it mean?
>
> It is an extension of the current command line options:
>
> --dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
> --dynamic-list FILE Read dynamic list
But you said it was like -Bsymbolic for function symbols only. What
is the connection between C++ typeinfo and that? (Hint: Java doesn't
use C++ typeinfo, but -Bsymbolic for function symbols only would be
very useful.)
Andrew.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 13:51 ` Andrew Haley
@ 2007-01-09 13:56 ` H. J. Lu
2007-01-09 14:02 ` Andrew Haley
0 siblings, 1 reply; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 13:56 UTC (permalink / raw)
To: Andrew Haley; +Cc: binutils, gcc
On Tue, Jan 09, 2007 at 01:51:00PM +0000, Andrew Haley wrote:
> H. J. Lu writes:
> > On Tue, Jan 09, 2007 at 01:38:00PM +0000, Andrew Haley wrote:
> > > H. J. Lu writes:
> > > > I am enclosing a patch to implement a new linker swicth,
> > > > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > > > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > > > and Linux/ia64. There are only a few regressions. The function calls
> > > > within the new resulting DSOs will bind locally. It speeds up
> > > > the enclosed C++ testcase by
> > > >
> > > > 1. 23% on ia64.
> > > > 2. 6% on ia32.
> > > > 3. 3% on x86-64.
> > > >
> > > > Should we consider such optimization?
> > >
> > > That's a terrible name for the option. What does it mean?
> >
> > It is an extension of the current command line options:
> >
> > --dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
> > --dynamic-list FILE Read dynamic list
>
> But you said it was like -Bsymbolic for function symbols only. What
> is the connection between C++ typeinfo and that? (Hint: Java doesn't
> use C++ typeinfo, but -Bsymbolic for function symbols only would be
> very useful.)
--dynamic-list is a generic linker feature. Users have to provide a
list of symbols, which will be bound dynamically and everything else
is bound locally. --dynamic-list-cpp-typeinfo includes a prefined
list for C++ typeinfo. --dynamic-list-data puts data symbols on
the dynamic list.
H.J.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 13:56 ` H. J. Lu
@ 2007-01-09 14:02 ` Andrew Haley
2007-01-09 14:18 ` H. J. Lu
0 siblings, 1 reply; 15+ messages in thread
From: Andrew Haley @ 2007-01-09 14:02 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils, gcc
H. J. Lu writes:
> On Tue, Jan 09, 2007 at 01:51:00PM +0000, Andrew Haley wrote:
> > H. J. Lu writes:
> > > On Tue, Jan 09, 2007 at 01:38:00PM +0000, Andrew Haley wrote:
> > > > H. J. Lu writes:
> > > > > I am enclosing a patch to implement a new linker swicth,
> > > > > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > > > > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > > > > and Linux/ia64. There are only a few regressions. The function calls
> > > > > within the new resulting DSOs will bind locally. It speeds up
> > > > > the enclosed C++ testcase by
> > > > >
> > > > > 1. 23% on ia64.
> > > > > 2. 6% on ia32.
> > > > > 3. 3% on x86-64.
> > > > >
> > > > > Should we consider such optimization?
> > > >
> > > > That's a terrible name for the option. What does it mean?
> > >
> > > It is an extension of the current command line options:
> > >
> > > --dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
> > > --dynamic-list FILE Read dynamic list
> >
> > But you said it was like -Bsymbolic for function symbols only. What
> > is the connection between C++ typeinfo and that? (Hint: Java doesn't
> > use C++ typeinfo, but -Bsymbolic for function symbols only would be
> > very useful.)
>
> --dynamic-list is a generic linker feature. Users have to provide a
> list of symbols, which will be bound dynamically and everything else
> is bound locally. --dynamic-list-cpp-typeinfo includes a prefined
> list for C++ typeinfo. --dynamic-list-data puts data symbols on
> the dynamic list.
OK, so in the case of --dynamic-list-data, there is no user-supplied
list. Instead, there's (conceptually) an automatically-generated
list, which contains every symbol that doesn't point to a function.
Can't you just call the new option -Bsymbolic-functions? At least
then people like me might have an outside chance of remembering it.
Andrew.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 14:02 ` Andrew Haley
@ 2007-01-09 14:18 ` H. J. Lu
2007-01-09 17:42 ` H. J. Lu
0 siblings, 1 reply; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 14:18 UTC (permalink / raw)
To: Andrew Haley; +Cc: binutils, gcc
On Tue, Jan 09, 2007 at 02:01:53PM +0000, Andrew Haley wrote:
> H. J. Lu writes:
> > On Tue, Jan 09, 2007 at 01:51:00PM +0000, Andrew Haley wrote:
> > > H. J. Lu writes:
> > > > On Tue, Jan 09, 2007 at 01:38:00PM +0000, Andrew Haley wrote:
> > > > > H. J. Lu writes:
> > > > > > I am enclosing a patch to implement a new linker swicth,
> > > > > > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > > > > > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > > > > > and Linux/ia64. There are only a few regressions. The function calls
> > > > > > within the new resulting DSOs will bind locally. It speeds up
> > > > > > the enclosed C++ testcase by
> > > > > >
> > > > > > 1. 23% on ia64.
> > > > > > 2. 6% on ia32.
> > > > > > 3. 3% on x86-64.
> > > > > >
> > > > > > Should we consider such optimization?
> > > > >
> > > > > That's a terrible name for the option. What does it mean?
> > > >
> > > > It is an extension of the current command line options:
> > > >
> > > > --dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
> > > > --dynamic-list FILE Read dynamic list
> > >
> > > But you said it was like -Bsymbolic for function symbols only. What
> > > is the connection between C++ typeinfo and that? (Hint: Java doesn't
> > > use C++ typeinfo, but -Bsymbolic for function symbols only would be
> > > very useful.)
> >
> > --dynamic-list is a generic linker feature. Users have to provide a
> > list of symbols, which will be bound dynamically and everything else
> > is bound locally. --dynamic-list-cpp-typeinfo includes a prefined
> > list for C++ typeinfo. --dynamic-list-data puts data symbols on
> > the dynamic list.
>
> OK, so in the case of --dynamic-list-data, there is no user-supplied
> list. Instead, there's (conceptually) an automatically-generated
> list, which contains every symbol that doesn't point to a function.
> Can't you just call the new option -Bsymbolic-functions? At least
> then people like me might have an outside chance of remembering it.
Here is the updated patch to use -Bsymbolic-functions instead.
H.J.
---
bfd/
2007-01-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* elf-bfd.h (bfd_elf_link_mark_dynamic_symbol): Add an
argument, Elf_Internal_Sym *.
* elflink.c (bfd_elf_link_mark_dynamic_symbol): Mark a data
symbol dynamic if info->symbolic_functions is TRUE.
(bfd_elf_record_link_assignment): Updated call to
bfd_elf_record_link_assignment.
(_bfd_elf_merge_symbol): Likewise. Always call
bfd_elf_link_mark_dynamic_symbol.
include/
2007-01-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* bfdlink.h (bfd_link_info): Rename dynamic to dynamic_list.
Add dynamic and symbolic_functions.
ld/
2007-01-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* ldlang.c (lang_process): Change link_info.dynamic to
link_info.dynamic_list.
(lang_append_dynamic_list): Likewise.
* ldmain.c (main): Likewise. Initialize link_info.dynamic and
link_info.symbolic_functions to FALSE.
* lexsup.c (option_values): Add OPTION_SYMBOLIC_FUNCTIONS.
(ld_options): Add -Bsymbolic-functions.
(parse_args): Change link_info.dynamic to link_info.dynamic_list.
Set link_info.symbolic_functions to TRUE for -Bsymbolic-functions.
Set link_info.dynamic to TRUE for --dynamic-list and
--dynamic-list-cpp-typeinfo.
--- binutils/bfd/elf-bfd.h.data 2007-01-09 05:49:14.000000000 -0800
+++ binutils/bfd/elf-bfd.h 2007-01-09 06:15:11.000000000 -0800
@@ -1858,7 +1858,8 @@ extern int bfd_elf_link_record_local_dyn
(struct bfd_link_info *, bfd *, long);
extern void bfd_elf_link_mark_dynamic_symbol
- (struct bfd_link_info *, struct elf_link_hash_entry *);
+ (struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *);
extern bfd_boolean _bfd_elf_close_and_cleanup
(bfd *);
--- binutils/bfd/elflink.c.data 2007-01-09 05:49:14.000000000 -0800
+++ binutils/bfd/elflink.c 2007-01-09 06:15:11.000000000 -0800
@@ -454,14 +454,22 @@ bfd_elf_link_record_dynamic_symbol (stru
void
bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *info,
- struct elf_link_hash_entry *h)
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
{
- struct bfd_elf_dynamic_list *d = info->dynamic;
+ struct bfd_elf_dynamic_list *d = info->dynamic_list;
- if (d == NULL || info->relocatable)
+ /* It may be called more than once on the same H. */
+ if(h->dynamic || info->relocatable)
return;
- if ((*d->match) (&d->head, NULL, h->root.root.string))
+ if ((info->symbolic_functions
+ && (h->type == STT_OBJECT
+ || (sym != NULL
+ && ELF_ST_TYPE (sym->st_info) == STT_OBJECT)))
+ || (d != NULL
+ && h->root.type == bfd_link_hash_new
+ && (*d->match) (&d->head, NULL, h->root.root.string)))
h->dynamic = 1;
}
@@ -499,7 +507,7 @@ bfd_elf_record_link_assignment (bfd *out
if (h->root.type == bfd_link_hash_new)
{
- bfd_elf_link_mark_dynamic_symbol (info, h);
+ bfd_elf_link_mark_dynamic_symbol (info, h, NULL);
h->non_elf = 0;
}
@@ -906,13 +914,17 @@ _bfd_elf_merge_symbol (bfd *abfd,
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ /* We have to check it for every instance since the first few may be
+ refereences and not all compilers emit symbol type for undefined
+ symbols. */
+ bfd_elf_link_mark_dynamic_symbol (info, h, sym);
+
/* If we just created the symbol, mark it as being an ELF symbol.
Other than that, there is nothing to do--there is no merge issue
with a newly defined symbol--so we just return. */
if (h->root.type == bfd_link_hash_new)
{
- bfd_elf_link_mark_dynamic_symbol (info, h);
h->non_elf = 0;
return TRUE;
}
--- binutils/include/bfdlink.h.data 2006-10-30 15:29:39.000000000 -0800
+++ binutils/include/bfdlink.h 2007-01-09 06:15:37.000000000 -0800
@@ -246,6 +246,9 @@ struct bfd_link_info
/* TRUE if BFD should pre-bind symbols in a shared object. */
unsigned int symbolic: 1;
+ /* TRUE if BFD should pre-bind function symbols in a shared object. */
+ unsigned int symbolic_functions: 1;
+
/* TRUE if BFD should export all symbols in the dynamic symbol table
of an executable, rather than only those used. */
unsigned int export_dynamic: 1;
@@ -340,6 +343,10 @@ struct bfd_link_info
caching ELF symbol buffer. */
unsigned int reduce_memory_overheads: 1;
+ /* TRUE if some symbols have to be dynamic, controlled by
+ --dynamic-list command line options. */
+ unsigned int dynamic: 1;
+
/* What to do with unresolved symbols in an object file.
When producing executables the default is GENERATE_ERROR.
When producing shared libraries the default is IGNORE. The
@@ -440,7 +447,7 @@ struct bfd_link_info
bfd_vma relro_start, relro_end;
/* List of symbols should be dynamic. */
- struct bfd_elf_dynamic_list *dynamic;
+ struct bfd_elf_dynamic_list *dynamic_list;
};
/* This structures holds a set of callback functions. These are
--- binutils/ld/ldlang.c.data 2007-01-09 05:49:14.000000000 -0800
+++ binutils/ld/ldlang.c 2007-01-09 06:15:11.000000000 -0800
@@ -5732,8 +5732,8 @@ void
lang_process (void)
{
/* Finalize dynamic list. */
- if (link_info.dynamic)
- lang_finalize_version_expr_head (&link_info.dynamic->head);
+ if (link_info.dynamic_list)
+ lang_finalize_version_expr_head (&link_info.dynamic_list->head);
current_target = default_target;
@@ -7047,13 +7047,13 @@ lang_add_unique (const char *name)
void
lang_append_dynamic_list (struct bfd_elf_version_expr *dynamic)
{
- if (link_info.dynamic)
+ if (link_info.dynamic_list)
{
struct bfd_elf_version_expr *tail;
for (tail = dynamic; tail->next != NULL; tail = tail->next)
;
- tail->next = link_info.dynamic->head.list;
- link_info.dynamic->head.list = dynamic;
+ tail->next = link_info.dynamic_list->head.list;
+ link_info.dynamic_list->head.list = dynamic;
}
else
{
@@ -7062,7 +7062,7 @@ lang_append_dynamic_list (struct bfd_elf
d = xcalloc (1, sizeof *d);
d->head.list = dynamic;
d->match = lang_vers_match;
- link_info.dynamic = d;
+ link_info.dynamic_list = d;
}
}
--- binutils/ld/ldmain.c.data 2006-10-30 15:29:40.000000000 -0800
+++ binutils/ld/ldmain.c 2007-01-09 06:15:11.000000000 -0800
@@ -318,7 +318,9 @@ main (int argc, char **argv)
link_info.warn_shared_textrel = FALSE;
link_info.gc_sections = FALSE;
link_info.print_gc_sections = FALSE;
- link_info.dynamic = NULL;
+ link_info.dynamic = FALSE;
+ link_info.dynamic_list = NULL;
+ link_info.symbolic_functions = FALSE;
link_info.reduce_memory_overheads = FALSE;
config.maxpagesize = 0;
--- binutils/ld/lexsup.c.data 2006-10-30 15:29:40.000000000 -0800
+++ binutils/ld/lexsup.c 2007-01-09 06:15:11.000000000 -0800
@@ -97,6 +97,7 @@ enum option_values
OPTION_SORT_SECTION,
OPTION_STATS,
OPTION_SYMBOLIC,
+ OPTION_SYMBOLIC_FUNCTIONS,
OPTION_TASK_LINK,
OPTION_TBSS,
OPTION_TDATA,
@@ -346,6 +347,8 @@ static const struct ld_option ld_options
'\0', NULL, NULL, ONE_DASH },
{ {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
'\0', NULL, N_("Bind global references locally"), ONE_DASH },
+ { {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS},
+ '\0', NULL, N_("Bind global function references locally"), ONE_DASH },
{ {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
'\0', NULL, N_("Check section addresses for overlaps (default)"),
TWO_DASHES },
@@ -1133,6 +1136,10 @@ parse_args (unsigned argc, char **argv)
case OPTION_SYMBOLIC:
link_info.symbolic = TRUE;
break;
+ case OPTION_SYMBOLIC_FUNCTIONS:
+ link_info.symbolic_functions = TRUE;
+ link_info.dynamic = TRUE;
+ break;
case 't':
trace_files = TRUE;
break;
@@ -1246,6 +1253,7 @@ parse_args (unsigned argc, char **argv)
break;
case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
lang_append_dynamic_list_cpp_typeinfo ();
+ link_info.dynamic = TRUE;
break;
case OPTION_DYNAMIC_LIST:
/* This option indicates a small script that only specifies
@@ -1260,6 +1268,7 @@ parse_args (unsigned argc, char **argv)
parser_input = input_dynamic_list;
yyparse ();
}
+ link_info.dynamic = TRUE;
break;
case OPTION_WARN_COMMON:
config.warn_common = TRUE;
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 4:23 ` H. J. Lu
@ 2007-01-09 14:50 ` H. J. Lu
2007-01-09 15:42 ` Paolo Bonzini
0 siblings, 1 reply; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 14:50 UTC (permalink / raw)
To: Andrew Pinski; +Cc: binutils, gcc
On Mon, Jan 08, 2007 at 08:23:39PM -0800, H. J. Lu wrote:
> On Mon, Jan 08, 2007 at 08:09:59PM -0800, Andrew Pinski wrote:
> > On Mon, 2007-01-08 at 18:25 -0800, H. J. Lu wrote:
> > > I am enclosing a patch to implement a new linker swicth,
> > > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > > and Linux/ia64. There are only a few regressions. The function calls
> > > within the new resulting DSOs will bind locally. It speeds up
> > > the enclosed C++ testcase by
> > >
> > > 1. 23% on ia64.
> > > 2. 6% on ia32.
> > > 3. 3% on x86-64.
> > >
> > > Should we consider such optimization?
> >
> > The real question is, does this work with operator new?
> >
> > In that if I a C++ developer provides a seperate operator new (and
> > delete), does libstdc++ use that one as required by the C++ standard?
>
> These are the regressions I was talking about. I can support them with
> a new linker switch. So far, we have
>
> --dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
> --dynamic-list FILE Read dynamic list
>
> My current proposal adds
>
> --dynamic-list-data Add data symbols to dynamic list
>
> I can add a new one
>
> --dynamic-list-cpp-new Add C++ new/delete to dynamic list
>
> Then we can build libstdc++ with
>
> --dynamic-list-data --dynamic-list-cpp-new
>
I am testing this patch now. It should fix the regresions when
libstdc++ is built with
-Bsymbolic-functions --dynamic-list-cpp-new
H.J.
----
2007-01-09 H.J. Lu <hongjiu.lu@intel.com>
* ldlang.c (lang_append_dynamic_list_cpp_new): New.
* ldlang.h (lang_append_dynamic_list_cpp_new): Likewise.
* lexsup.c (option_values): Add OPTION_DYNAMIC_LIST_CPP_NEW.
(ld_options): Add entries for OPTION_DYNAMIC_LIST_CPP_NEW.
(parse_args): Handle OPTION_DYNAMIC_LIST_CPP_NEW.
--- ld/ldlang.c.new 2007-01-09 06:15:11.000000000 -0800
+++ ld/ldlang.c 2007-01-09 06:20:41.000000000 -0800
@@ -7086,3 +7086,24 @@ lang_append_dynamic_list_cpp_typeinfo (v
lang_append_dynamic_list (dynamic);
}
+
+/* Append the list of C++ operator new and delete dynamic symbols to the
+ existing one. */
+
+void
+lang_append_dynamic_list_cpp_new (void)
+{
+ const char * symbols [] =
+ {
+ "operator new*",
+ "operator delete*"
+ };
+ struct bfd_elf_version_expr *dynamic = NULL;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE (symbols); i++)
+ dynamic = lang_new_vers_pattern (dynamic, symbols [i], "C++",
+ FALSE);
+
+ lang_append_dynamic_list (dynamic);
+}
--- ld/ldlang.h.new 2006-10-25 07:31:37.000000000 -0700
+++ ld/ldlang.h 2007-01-09 06:21:08.000000000 -0800
@@ -607,6 +607,7 @@ extern void lang_register_vers_node
(const char *, struct bfd_elf_version_tree *, struct bfd_elf_version_deps *);
extern void lang_append_dynamic_list (struct bfd_elf_version_expr *);
extern void lang_append_dynamic_list_cpp_typeinfo (void);
+extern void lang_append_dynamic_list_cpp_new (void);
bfd_boolean unique_section_p
(const asection *);
extern void lang_add_unique
--- ld/lexsup.c.new 2007-01-09 06:15:11.000000000 -0800
+++ ld/lexsup.c 2007-01-09 06:22:30.000000000 -0800
@@ -109,6 +109,7 @@ enum option_values
OPTION_VERSION_SCRIPT,
OPTION_VERSION_EXPORTS_SECTION,
OPTION_DYNAMIC_LIST,
+ OPTION_DYNAMIC_LIST_CPP_NEW,
OPTION_DYNAMIC_LIST_CPP_TYPEINFO,
OPTION_WARN_COMMON,
OPTION_WARN_CONSTRUCTORS,
@@ -506,6 +507,8 @@ static const struct ld_option ld_options
OPTION_VERSION_EXPORTS_SECTION },
'\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
"\t\t\t\tSYMBOL as the version."), TWO_DASHES },
+ { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
+ '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES },
{ {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
'\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
{ {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
@@ -1255,6 +1258,10 @@ parse_args (unsigned argc, char **argv)
lang_append_dynamic_list_cpp_typeinfo ();
link_info.dynamic = TRUE;
break;
+ case OPTION_DYNAMIC_LIST_CPP_NEW:
+ lang_append_dynamic_list_cpp_new ();
+ link_info.dynamic = TRUE;
+ break;
case OPTION_DYNAMIC_LIST:
/* This option indicates a small script that only specifies
a dynamic list. Read it, but don't assume that we've
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 14:50 ` H. J. Lu
@ 2007-01-09 15:42 ` Paolo Bonzini
2007-01-09 15:52 ` H. J. Lu
0 siblings, 1 reply; 15+ messages in thread
From: Paolo Bonzini @ 2007-01-09 15:42 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils, gcc
> I am testing this patch now. It should fix the regresions when
> libstdc++ is built with
>
> -Bsymbolic-functions --dynamic-list-cpp-new
What about just --dynamic-list-cpp that enables the new behavior and
implies --dynamic-list-cpp-typeinfo (I know that it is useless in this
particular case, since C++ typeinfo is data, but in general such an
option sounds more useful than only --dynamic-list-cpp-new).
Paolo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 15:42 ` Paolo Bonzini
@ 2007-01-09 15:52 ` H. J. Lu
2007-01-09 22:57 ` H. J. Lu
0 siblings, 1 reply; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 15:52 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: binutils, gcc
On Tue, Jan 09, 2007 at 04:42:41PM +0100, Paolo Bonzini wrote:
>
> >I am testing this patch now. It should fix the regresions when
> >libstdc++ is built with
> >
> >-Bsymbolic-functions --dynamic-list-cpp-new
I tested it on gcc 4.2 with C, C++, Java and Fortran on Linux/x86-64.
There is no regression.
>
> What about just --dynamic-list-cpp that enables the new behavior and
> implies --dynamic-list-cpp-typeinfo (I know that it is useless in this
> particular case, since C++ typeinfo is data, but in general such an
> option sounds more useful than only --dynamic-list-cpp-new).
I think you only need --dynamic-list-cpp-new for building libstdc++.so.
-Bsymbolic-functions should be sufficient for other C++ shared
libraries.
H.J.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 14:18 ` H. J. Lu
@ 2007-01-09 17:42 ` H. J. Lu
2007-01-09 19:21 ` H. J. Lu
0 siblings, 1 reply; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 17:42 UTC (permalink / raw)
To: Andrew Haley; +Cc: binutils, gcc
On Tue, Jan 09, 2007 at 06:18:19AM -0800, H. J. Lu wrote:
> On Tue, Jan 09, 2007 at 02:01:53PM +0000, Andrew Haley wrote:
> > H. J. Lu writes:
> > > On Tue, Jan 09, 2007 at 01:51:00PM +0000, Andrew Haley wrote:
> > > > H. J. Lu writes:
> > > > > On Tue, Jan 09, 2007 at 01:38:00PM +0000, Andrew Haley wrote:
> > > > > > H. J. Lu writes:
> > > > > > > I am enclosing a patch to implement a new linker swicth,
> > > > > > > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > > > > > > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > > > > > > and Linux/ia64. There are only a few regressions. The function calls
> > > > > > > within the new resulting DSOs will bind locally. It speeds up
> > > > > > > the enclosed C++ testcase by
> > > > > > >
> > > > > > > 1. 23% on ia64.
> > > > > > > 2. 6% on ia32.
> > > > > > > 3. 3% on x86-64.
> > > > > > >
> > > > > > > Should we consider such optimization?
> > > > > >
> > > > > > That's a terrible name for the option. What does it mean?
> > > > >
> > > > > It is an extension of the current command line options:
> > > > >
> > > > > --dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
> > > > > --dynamic-list FILE Read dynamic list
> > > >
> > > > But you said it was like -Bsymbolic for function symbols only. What
> > > > is the connection between C++ typeinfo and that? (Hint: Java doesn't
> > > > use C++ typeinfo, but -Bsymbolic for function symbols only would be
> > > > very useful.)
> > >
> > > --dynamic-list is a generic linker feature. Users have to provide a
> > > list of symbols, which will be bound dynamically and everything else
> > > is bound locally. --dynamic-list-cpp-typeinfo includes a prefined
> > > list for C++ typeinfo. --dynamic-list-data puts data symbols on
> > > the dynamic list.
> >
> > OK, so in the case of --dynamic-list-data, there is no user-supplied
> > list. Instead, there's (conceptually) an automatically-generated
> > list, which contains every symbol that doesn't point to a function.
> > Can't you just call the new option -Bsymbolic-functions? At least
> > then people like me might have an outside chance of remembering it.
>
> Here is the updated patch to use -Bsymbolic-functions instead.
>
I just realized that --dynamic-list-data is -Bsymbolic for function
symbols only when you build shared libraries. We can use
--dynamic-list-data on executables to make global data symbols
dynamic so that dlopened shared libraries can reference them. We can
make -Bsymbolic-functions an alias of --dynamic-list-data. But
we still need --dynamic-list-data since -Bsymbolic doesn't apply to
executables.
H.J.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 17:42 ` H. J. Lu
@ 2007-01-09 19:21 ` H. J. Lu
0 siblings, 0 replies; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 19:21 UTC (permalink / raw)
To: Andrew Haley; +Cc: binutils, gcc
On Tue, Jan 09, 2007 at 09:42:40AM -0800, H. J. Lu wrote:
> On Tue, Jan 09, 2007 at 06:18:19AM -0800, H. J. Lu wrote:
> > On Tue, Jan 09, 2007 at 02:01:53PM +0000, Andrew Haley wrote:
> > > H. J. Lu writes:
> > > > On Tue, Jan 09, 2007 at 01:51:00PM +0000, Andrew Haley wrote:
> > > > > H. J. Lu writes:
> > > > > > On Tue, Jan 09, 2007 at 01:38:00PM +0000, Andrew Haley wrote:
> > > > > > > H. J. Lu writes:
> > > > > > > > I am enclosing a patch to implement a new linker swicth,
> > > > > > > > --dynamic-list-data. It is -Bsymbolic for function symbols only.
> > > > > > > > I tried it with C, C++, Java and Fortran on Linux/ia32, Linux/x86-64
> > > > > > > > and Linux/ia64. There are only a few regressions. The function calls
> > > > > > > > within the new resulting DSOs will bind locally. It speeds up
> > > > > > > > the enclosed C++ testcase by
> > > > > > > >
> > > > > > > > 1. 23% on ia64.
> > > > > > > > 2. 6% on ia32.
> > > > > > > > 3. 3% on x86-64.
> > > > > > > >
> > > > > > > > Should we consider such optimization?
> > > > > > >
> > > > > > > That's a terrible name for the option. What does it mean?
> > > > > >
> > > > > > It is an extension of the current command line options:
> > > > > >
> > > > > > --dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
> > > > > > --dynamic-list FILE Read dynamic list
> > > > >
> > > > > But you said it was like -Bsymbolic for function symbols only. What
> > > > > is the connection between C++ typeinfo and that? (Hint: Java doesn't
> > > > > use C++ typeinfo, but -Bsymbolic for function symbols only would be
> > > > > very useful.)
> > > >
> > > > --dynamic-list is a generic linker feature. Users have to provide a
> > > > list of symbols, which will be bound dynamically and everything else
> > > > is bound locally. --dynamic-list-cpp-typeinfo includes a prefined
> > > > list for C++ typeinfo. --dynamic-list-data puts data symbols on
> > > > the dynamic list.
> > >
> > > OK, so in the case of --dynamic-list-data, there is no user-supplied
> > > list. Instead, there's (conceptually) an automatically-generated
> > > list, which contains every symbol that doesn't point to a function.
> > > Can't you just call the new option -Bsymbolic-functions? At least
> > > then people like me might have an outside chance of remembering it.
> >
> > Here is the updated patch to use -Bsymbolic-functions instead.
> >
>
> I just realized that --dynamic-list-data is -Bsymbolic for function
> symbols only when you build shared libraries. We can use
> --dynamic-list-data on executables to make global data symbols
> dynamic so that dlopened shared libraries can reference them. We can
> make -Bsymbolic-functions an alias of --dynamic-list-data. But
> we still need --dynamic-list-data since -Bsymbolic doesn't apply to
> executables.
Here is the updated patch with testcases and document change.
H.J.
----
bfd/
2007-01-09 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* elf-bfd.h (bfd_elf_link_mark_dynamic_symbol): Add an
argument, Elf_Internal_Sym *.
* elflink.c (bfd_elf_link_mark_dynamic_symbol): Mark a data
symbol dynamic if info->dynamic_data is TRUE.
(bfd_elf_record_link_assignment): Updated call to
bfd_elf_record_link_assignment.
(_bfd_elf_merge_symbol): Likewise. Always call
bfd_elf_link_mark_dynamic_symbol.
include/
2007-01-09 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* bfdlink.h (bfd_link_info): Rename dynamic to dynamic_list.
Add dynamic and dynamic_data.
ld/
2007-01-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3831
* NEWS: Mention -Bsymbolic-functions and --dynamic-list-data.
* ld.texinfo: Document -Bsymbolic-functions and
--dynamic-list-data.
* ldlang.c (lang_process): Change link_info.dynamic to
link_info.dynamic_list.
(lang_append_dynamic_list): Likewise.
* ldmain.c (main): Likewise. Initialize link_info.dynamic and
link_info.dynamic_data to FALSE.
* lexsup.c (option_values): Add OPTION_DYNAMIC_LIST_DATA.
(ld_options): Add entries for -Bsymbolic-functions and
--dynamic-list-data. Make -Bsymbolic-functions an alias of
--dynamic-list-data.
(parse_args): Change link_info.dynamic to link_info.dynamic_list.
Set link_info.dynamic_data to TRUE for --dynamic-list-data. Set
link_info.dynamic to TRUE for --dynamuc-list*.
ld/testsuite/
2007-01-09 H.J. Lu <hongjiu.lu@intel.com>
* ld-elf/shared.exp: Add tests for --dynamic-list-data.
--- binutils/bfd/elf-bfd.h.data 2007-01-09 09:00:51.000000000 -0800
+++ binutils/bfd/elf-bfd.h 2007-01-09 09:00:51.000000000 -0800
@@ -1858,7 +1858,8 @@ extern int bfd_elf_link_record_local_dyn
(struct bfd_link_info *, bfd *, long);
extern void bfd_elf_link_mark_dynamic_symbol
- (struct bfd_link_info *, struct elf_link_hash_entry *);
+ (struct bfd_link_info *, struct elf_link_hash_entry *,
+ Elf_Internal_Sym *);
extern bfd_boolean _bfd_elf_close_and_cleanup
(bfd *);
--- binutils/bfd/elflink.c.data 2007-01-09 09:00:51.000000000 -0800
+++ binutils/bfd/elflink.c 2007-01-09 09:59:22.000000000 -0800
@@ -454,14 +454,22 @@ bfd_elf_link_record_dynamic_symbol (stru
void
bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *info,
- struct elf_link_hash_entry *h)
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
{
- struct bfd_elf_dynamic_list *d = info->dynamic;
+ struct bfd_elf_dynamic_list *d = info->dynamic_list;
- if (d == NULL || info->relocatable)
+ /* It may be called more than once on the same H. */
+ if(h->dynamic || info->relocatable)
return;
- if ((*d->match) (&d->head, NULL, h->root.root.string))
+ if ((info->dynamic_data
+ && (h->type == STT_OBJECT
+ || (sym != NULL
+ && ELF_ST_TYPE (sym->st_info) == STT_OBJECT)))
+ || (d != NULL
+ && h->root.type == bfd_link_hash_new
+ && (*d->match) (&d->head, NULL, h->root.root.string)))
h->dynamic = 1;
}
@@ -499,7 +507,7 @@ bfd_elf_record_link_assignment (bfd *out
if (h->root.type == bfd_link_hash_new)
{
- bfd_elf_link_mark_dynamic_symbol (info, h);
+ bfd_elf_link_mark_dynamic_symbol (info, h, NULL);
h->non_elf = 0;
}
@@ -906,13 +914,17 @@ _bfd_elf_merge_symbol (bfd *abfd,
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ /* We have to check it for every instance since the first few may be
+ refereences and not all compilers emit symbol type for undefined
+ symbols. */
+ bfd_elf_link_mark_dynamic_symbol (info, h, sym);
+
/* If we just created the symbol, mark it as being an ELF symbol.
Other than that, there is nothing to do--there is no merge issue
with a newly defined symbol--so we just return. */
if (h->root.type == bfd_link_hash_new)
{
- bfd_elf_link_mark_dynamic_symbol (info, h);
h->non_elf = 0;
return TRUE;
}
--- binutils/include/bfdlink.h.data 2006-10-30 15:25:51.000000000 -0800
+++ binutils/include/bfdlink.h 2007-01-09 09:58:52.000000000 -0800
@@ -340,6 +340,13 @@ struct bfd_link_info
caching ELF symbol buffer. */
unsigned int reduce_memory_overheads: 1;
+ /* TRUE if all data symbols should be dynamic. */
+ unsigned int dynamic_data: 1;
+
+ /* TRUE if some symbols have to be dynamic, controlled by
+ --dynamic-list command line options. */
+ unsigned int dynamic: 1;
+
/* What to do with unresolved symbols in an object file.
When producing executables the default is GENERATE_ERROR.
When producing shared libraries the default is IGNORE. The
@@ -440,7 +447,7 @@ struct bfd_link_info
bfd_vma relro_start, relro_end;
/* List of symbols should be dynamic. */
- struct bfd_elf_dynamic_list *dynamic;
+ struct bfd_elf_dynamic_list *dynamic_list;
};
/* This structures holds a set of callback functions. These are
--- binutils/ld/NEWS.data 2006-09-20 04:35:09.000000000 -0700
+++ binutils/ld/NEWS 2007-01-09 11:18:06.000000000 -0800
@@ -1,4 +1,7 @@
-*- text -*-
+* ELF: Add -Bsymbolic-functions and --dynamic-list-data, builtin list
+ for --dynamic-list, which put global data symbols on the dynamic list.
+
* Add support for x86_64 PE+ target.
* Add support for Score target.
--- binutils/ld/ld.texinfo.data 2006-12-05 11:28:02.000000000 -0800
+++ binutils/ld/ld.texinfo 2007-01-09 11:14:06.000000000 -0800
@@ -1130,6 +1130,14 @@ for a program linked against a shared li
within the shared library. This option is only meaningful on ELF
platforms which support shared libraries.
+@kindex -Bsymbolic-functions
+@item -Bsymbolic-functions
+When creating a shared library, bind references to global function
+symbols to the definition within the shared library, if any.
+@option{-Bsymbolic-functions} is an alias for @option{--dynamic-list-data}.
+This option is only meaningful on ELF platforms which support shared
+libraries.
+
@kindex --dynamic-list=@var{dynamic-list-file}
@item --dynamic-list=@var{dynamic-list-file}
Specify the name of a dynamic list file to the linker. This is
@@ -1143,6 +1151,10 @@ which support shared libraries.
The format of the dynamic list is the same as the version node without
scope and node name. See @ref{VERSION} for more information.
+@kindex --dynamic-list-data
+@item --dynamic-list-data
+Include all global data symbols to the dynamic list.
+
@kindex --dynamic-list-cpp-typeinfo
@item --dynamic-list-cpp-typeinfo
Provide the builtin dynamic list for C++ runtime type identification.
--- binutils/ld/ldlang.c.data 2007-01-09 09:00:51.000000000 -0800
+++ binutils/ld/ldlang.c 2007-01-09 09:00:51.000000000 -0800
@@ -5732,8 +5732,8 @@ void
lang_process (void)
{
/* Finalize dynamic list. */
- if (link_info.dynamic)
- lang_finalize_version_expr_head (&link_info.dynamic->head);
+ if (link_info.dynamic_list)
+ lang_finalize_version_expr_head (&link_info.dynamic_list->head);
current_target = default_target;
@@ -7047,13 +7047,13 @@ lang_add_unique (const char *name)
void
lang_append_dynamic_list (struct bfd_elf_version_expr *dynamic)
{
- if (link_info.dynamic)
+ if (link_info.dynamic_list)
{
struct bfd_elf_version_expr *tail;
for (tail = dynamic; tail->next != NULL; tail = tail->next)
;
- tail->next = link_info.dynamic->head.list;
- link_info.dynamic->head.list = dynamic;
+ tail->next = link_info.dynamic_list->head.list;
+ link_info.dynamic_list->head.list = dynamic;
}
else
{
@@ -7062,7 +7062,7 @@ lang_append_dynamic_list (struct bfd_elf
d = xcalloc (1, sizeof *d);
d->head.list = dynamic;
d->match = lang_vers_match;
- link_info.dynamic = d;
+ link_info.dynamic_list = d;
}
}
--- binutils/ld/ldmain.c.data 2006-10-30 15:25:51.000000000 -0800
+++ binutils/ld/ldmain.c 2007-01-09 10:00:33.000000000 -0800
@@ -318,7 +318,9 @@ main (int argc, char **argv)
link_info.warn_shared_textrel = FALSE;
link_info.gc_sections = FALSE;
link_info.print_gc_sections = FALSE;
- link_info.dynamic = NULL;
+ link_info.dynamic = FALSE;
+ link_info.dynamic_list = NULL;
+ link_info.dynamic_data = FALSE;
link_info.reduce_memory_overheads = FALSE;
config.maxpagesize = 0;
--- binutils/ld/lexsup.c.data 2006-10-30 15:25:51.000000000 -0800
+++ binutils/ld/lexsup.c 2007-01-09 10:00:23.000000000 -0800
@@ -109,6 +109,7 @@ enum option_values
OPTION_VERSION_EXPORTS_SECTION,
OPTION_DYNAMIC_LIST,
OPTION_DYNAMIC_LIST_CPP_TYPEINFO,
+ OPTION_DYNAMIC_LIST_DATA,
OPTION_WARN_COMMON,
OPTION_WARN_CONSTRUCTORS,
OPTION_WARN_FATAL,
@@ -503,6 +504,10 @@ static const struct ld_option ld_options
OPTION_VERSION_EXPORTS_SECTION },
'\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
"\t\t\t\tSYMBOL as the version."), TWO_DASHES },
+ { {"Bsymbolic-functions", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
+ '\0', NULL, N_("Bind global function references locally"), ONE_DASH },
+ { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
+ '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
{ {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
'\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
{ {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
@@ -1244,8 +1249,13 @@ parse_args (unsigned argc, char **argv)
.exports sections. */
command_line.version_exports_section = optarg;
break;
+ case OPTION_DYNAMIC_LIST_DATA:
+ link_info.dynamic_data = TRUE;
+ link_info.dynamic = TRUE;
+ break;
case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
lang_append_dynamic_list_cpp_typeinfo ();
+ link_info.dynamic = TRUE;
break;
case OPTION_DYNAMIC_LIST:
/* This option indicates a small script that only specifies
@@ -1260,6 +1270,7 @@ parse_args (unsigned argc, char **argv)
parser_input = input_dynamic_list;
yyparse ();
}
+ link_info.dynamic = TRUE;
break;
case OPTION_WARN_COMMON:
config.warn_common = TRUE;
--- binutils/ld/testsuite/ld-elf/shared.exp.data 2006-10-18 09:23:24.000000000 -0700
+++ binutils/ld/testsuite/ld-elf/shared.exp 2007-01-09 10:46:32.000000000 -0800
@@ -72,15 +72,27 @@ set build_tests {
{"Build libdl2a.so with --dynamic-list=dl2.list"
"-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
{dl2.c dl2xxx.c} {} "libdl2a.so"}
+ {"Build libdl2a.so with --dynamic-list-data"
+ "-shared -Wl,--dynamic-list-data" "-fPIC"
+ {dl2.c dl2xxx.c} {} "libdl2a.so"}
{"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
"-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
{dl2.c dl2xxx.c} {} "libdl2b.so"}
+ {"Build libdl2b.so with --dynamic-list-data and dl2xxx.list"
+ "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
+ {dl2.c dl2xxx.c} {} "libdl2b.so"}
{"Build libdl4a.so with --dynamic-list=dl4.list"
"-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
{dl4.c dl4xxx.c} {} "libdl4a.so"}
+ {"Build libdl4a.so with --dynamic-list-data"
+ "-shared -Wl,--dynamic-list-data" "-fPIC"
+ {dl4.c dl4xxx.c} {} "libdl4a.so"}
{"Build libdl4b.so with --dynamic-list=dl4.list and dl4xxx.list"
"-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
{dl4.c dl4xxx.c} {} "libdl4b.so"}
+ {"Build libdl4b.so with --dynamic-list-data and dl4xxx.list"
+ "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
+ {dl4.c dl4xxx.c} {} "libdl4b.so"}
}
set run_tests {
@@ -120,9 +132,12 @@ set run_tests {
{"Run hidden libbar.so with versioned libfoo.so"
"tmpdir/libbarhfoov.so tmpdir/libfoov.so" ""
{main.c} "hidden" "hidden.out"}
- {"Run with dlopen on libdl1.so"
+ {"Run dl1 with --dynamic-list=dl1.list and dlopen on libdl1.so"
"--dynamic-list=dl1.list -ldl" ""
{dl1main.c} "dl1" "dl1.out"}
+ {"Run dl1 with --dynamic-list-data and dlopen on libdl1.so"
+ "--dynamic-list-data -ldl" ""
+ {dl1main.c} "dl1" "dl1.out"}
{"Run with libdl2a.so"
"tmpdir/libdl2a.so" ""
{dl2main.c} "dl2a" "dl2a.out"}
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: RFC: Speeding up libstdc++.so with --dynamic-list-data
2007-01-09 15:52 ` H. J. Lu
@ 2007-01-09 22:57 ` H. J. Lu
0 siblings, 0 replies; 15+ messages in thread
From: H. J. Lu @ 2007-01-09 22:57 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: binutils, gcc
On Tue, Jan 09, 2007 at 07:52:42AM -0800, H. J. Lu wrote:
> >
> > What about just --dynamic-list-cpp that enables the new behavior and
> > implies --dynamic-list-cpp-typeinfo (I know that it is useless in this
> > particular case, since C++ typeinfo is data, but in general such an
> > option sounds more useful than only --dynamic-list-cpp-new).
>
> I think you only need --dynamic-list-cpp-new for building libstdc++.so.
> -Bsymbolic-functions should be sufficient for other C++ shared
> libraries.
>
Here is a patch for --dynamic-list-cpp-new with a testcase.
H.J.
---
ld/
2007-01-09 H.J. Lu <hongjiu.lu@intel.com>
* NEWS: Mention --dynamic-list-cpp-new.
* ld.texinfo: Document --dynamic-list-cpp-new.
* ldlang.c (lang_append_dynamic_list_cpp_new): New.
* ldlang.h (lang_append_dynamic_list_cpp_new): Likewise.
* lexsup.c (option_values): Add OPTION_DYNAMIC_LIST_CPP_NEW.
(ld_options): Add entry for --dynamic-list-cpp-new.
(parse_args): Handle OPTION_DYNAMIC_LIST_CPP_NEW.
ld/testsuite/
2007-01-09 H.J. Lu <hongjiu.lu@intel.com>
* ld-elf/del.cc: New.
* ld-elf/dl5.cc: Likewise.
* ld-elf/dl5.out: Likewise.
* ld-elf/new.cc: Likewise.
* ld-elf/shared.exp: Add --dynamic-list-cpp-new testcase.
--- ld/NEWS.new 2007-01-09 11:34:46.000000000 -0800
+++ ld/NEWS 2007-01-09 11:34:53.000000000 -0800
@@ -1,4 +1,7 @@
-*- text -*-
+* ELF: Add --dynamic-list-cpp-new, which puts C++ operator new and
+ delete on the dynamic list.
+
* ELF: Add -Bsymbolic-functions and --dynamic-list-data, builtin list
for --dynamic-list, which puts global data symbols on the dynamic list.
--- ld/ld.texinfo.new 2007-01-09 11:22:59.000000000 -0800
+++ ld/ld.texinfo 2007-01-09 11:31:50.000000000 -0800
@@ -1155,6 +1155,11 @@ scope and node name. See @ref{VERSION}
@item --dynamic-list-data
Include all global data symbols to the dynamic list.
+@kindex --dynamic-list-cpp-new
+@item --dynamic-list-cpp-new
+Provide the builtin dynamic list for C++ operator new and delete. It
+is mainly useful for building shared libstdc++.
+
@kindex --dynamic-list-cpp-typeinfo
@item --dynamic-list-cpp-typeinfo
Provide the builtin dynamic list for C++ runtime type identification.
--- ld/ldlang.c.new 2007-01-09 11:22:59.000000000 -0800
+++ ld/ldlang.c 2007-01-09 11:22:59.000000000 -0800
@@ -7086,3 +7086,24 @@ lang_append_dynamic_list_cpp_typeinfo (v
lang_append_dynamic_list (dynamic);
}
+
+/* Append the list of C++ operator new and delete dynamic symbols to the
+ existing one. */
+
+void
+lang_append_dynamic_list_cpp_new (void)
+{
+ const char * symbols [] =
+ {
+ "operator new*",
+ "operator delete*"
+ };
+ struct bfd_elf_version_expr *dynamic = NULL;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE (symbols); i++)
+ dynamic = lang_new_vers_pattern (dynamic, symbols [i], "C++",
+ FALSE);
+
+ lang_append_dynamic_list (dynamic);
+}
--- ld/ldlang.h.new 2006-10-24 23:49:21.000000000 -0700
+++ ld/ldlang.h 2007-01-09 11:22:59.000000000 -0800
@@ -607,6 +607,7 @@ extern void lang_register_vers_node
(const char *, struct bfd_elf_version_tree *, struct bfd_elf_version_deps *);
extern void lang_append_dynamic_list (struct bfd_elf_version_expr *);
extern void lang_append_dynamic_list_cpp_typeinfo (void);
+extern void lang_append_dynamic_list_cpp_new (void);
bfd_boolean unique_section_p
(const asection *);
extern void lang_add_unique
--- ld/lexsup.c.new 2007-01-09 11:22:59.000000000 -0800
+++ ld/lexsup.c 2007-01-09 11:24:13.000000000 -0800
@@ -108,6 +108,7 @@ enum option_values
OPTION_VERSION_SCRIPT,
OPTION_VERSION_EXPORTS_SECTION,
OPTION_DYNAMIC_LIST,
+ OPTION_DYNAMIC_LIST_CPP_NEW,
OPTION_DYNAMIC_LIST_CPP_TYPEINFO,
OPTION_DYNAMIC_LIST_DATA,
OPTION_WARN_COMMON,
@@ -508,6 +509,8 @@ static const struct ld_option ld_options
'\0', NULL, N_("Bind global function references locally"), ONE_DASH },
{ {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
'\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
+ { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
+ '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES },
{ {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
'\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
{ {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
@@ -1257,6 +1260,10 @@ parse_args (unsigned argc, char **argv)
lang_append_dynamic_list_cpp_typeinfo ();
link_info.dynamic = TRUE;
break;
+ case OPTION_DYNAMIC_LIST_CPP_NEW:
+ lang_append_dynamic_list_cpp_new ();
+ link_info.dynamic = TRUE;
+ break;
case OPTION_DYNAMIC_LIST:
/* This option indicates a small script that only specifies
a dynamic list. Read it, but don't assume that we've
--- ld/testsuite/ld-elf/del.cc.new 2007-01-09 14:48:18.000000000 -0800
+++ ld/testsuite/ld-elf/del.cc 2007-01-09 12:58:35.000000000 -0800
@@ -0,0 +1,29 @@
+#include <new>
+
+extern "C" void free (void *);
+
+void
+operator delete (void *ptr, const std::nothrow_t&) throw ()
+{
+ if (ptr)
+ free (ptr);
+}
+
+void
+operator delete (void *ptr) throw ()
+{
+ if (ptr)
+ free (ptr);
+}
+
+void
+operator delete[] (void *ptr) throw ()
+{
+ ::operator delete (ptr);
+}
+
+void
+operator delete[] (void *ptr, const std::nothrow_t&) throw ()
+{
+ ::operator delete (ptr);
+}
--- ld/testsuite/ld-elf/dl5.cc.new 2007-01-09 14:48:18.000000000 -0800
+++ ld/testsuite/ld-elf/dl5.cc 2007-01-09 14:46:22.000000000 -0800
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <new>
+
+int pass = 0;
+
+void *
+operator new (size_t sz, const std::nothrow_t&) throw ()
+{
+ void *p;
+ pass++;
+ p = malloc(sz);
+ return p;
+}
+
+void *
+operator new (size_t sz) throw (std::bad_alloc)
+{
+ void *p;
+ pass++;
+ p = malloc(sz);
+ return p;
+}
+
+void
+operator delete (void *ptr) throw ()
+{
+ pass++;
+ if (ptr)
+ free (ptr);
+}
+
+class A
+{
+public:
+ A() {}
+ ~A() { }
+ int a;
+ int b;
+};
+
+
+int
+main (void)
+{
+ A *bb = new A[10];
+ delete [] bb;
+ bb = new (std::nothrow) A [10];
+ delete [] bb;
+
+ if (pass == 4)
+ {
+ printf ("PASS\n");
+ return 0;
+ }
+ else
+ {
+ printf ("FAIL\n");
+ return 1;
+ }
+}
--- ld/testsuite/ld-elf/dl5.out.new 2007-01-09 14:48:18.000000000 -0800
+++ ld/testsuite/ld-elf/dl5.out 2007-01-09 14:47:38.000000000 -0800
@@ -0,0 +1 @@
+PASS
--- ld/testsuite/ld-elf/new.cc.new 2007-01-09 14:48:18.000000000 -0800
+++ ld/testsuite/ld-elf/new.cc 2007-01-09 11:49:37.000000000 -0800
@@ -0,0 +1,48 @@
+#include <new>
+#include <exception_defines.h>
+
+using std::bad_alloc;
+
+extern "C" void *malloc (std::size_t);
+extern "C" void abort (void);
+
+void *
+operator new (std::size_t sz, const std::nothrow_t&) throw()
+{
+ void *p;
+
+ /* malloc (0) is unpredictable; avoid it. */
+ if (sz == 0)
+ sz = 1;
+ p = (void *) malloc (sz);
+ return p;
+}
+
+void *
+operator new (std::size_t sz) throw (std::bad_alloc)
+{
+ void *p;
+
+ /* malloc (0) is unpredictable; avoid it. */
+ if (sz == 0)
+ sz = 1;
+ p = (void *) malloc (sz);
+ while (p == 0)
+ {
+ ::abort();
+ }
+
+ return p;
+}
+
+void*
+operator new[] (std::size_t sz) throw (std::bad_alloc)
+{
+ return ::operator new(sz);
+}
+
+void *
+operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
+{
+ return ::operator new(sz, nothrow);
+}
--- ld/testsuite/ld-elf/shared.exp.new 2007-01-09 11:22:59.000000000 -0800
+++ ld/testsuite/ld-elf/shared.exp 2007-01-09 14:47:17.000000000 -0800
@@ -171,6 +171,9 @@ set build_cxx_tests {
{"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
"-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
{dl3.cc} {} "libdl3c.so" "c++"}
+ {"Build libdnew.so with -Bsymbolic-functions -dynamic-list-cpp-new"
+ "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
+ {del.cc new.cc} {} "libnew.so" "c++"}
}
set run_cxx_tests {
@@ -183,6 +186,9 @@ set run_cxx_tests {
{"Run with libdl3c.so"
"tmpdir/libdl3c.so" ""
{dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
+ {"Run with libnew.so"
+ "tmpdir/libnew.so" ""
+ {dl5.cc} "dl5" "dl5.out" "" "c++"}
}
run_cc_link_tests $build_cxx_tests
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2007-01-09 22:57 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-09 2:26 RFC: Speeding up libstdc++.so with --dynamic-list-data H. J. Lu
2007-01-09 4:10 ` Andrew Pinski
2007-01-09 4:23 ` H. J. Lu
2007-01-09 14:50 ` H. J. Lu
2007-01-09 15:42 ` Paolo Bonzini
2007-01-09 15:52 ` H. J. Lu
2007-01-09 22:57 ` H. J. Lu
2007-01-09 13:38 ` Andrew Haley
2007-01-09 13:41 ` H. J. Lu
2007-01-09 13:51 ` Andrew Haley
2007-01-09 13:56 ` H. J. Lu
2007-01-09 14:02 ` Andrew Haley
2007-01-09 14:18 ` H. J. Lu
2007-01-09 17:42 ` H. J. Lu
2007-01-09 19:21 ` H. J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).