mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-19 01:19:41 +08:00
binutils: Don't complain plugin with all LTO sections removed
When all LTO sections have been removed, the BFD lto_type is set to lto_non_ir_object by bfd_set_lto_type. In this case, don't complain needing a plugin when seeing a LTO slim symbol. bfd/ PR binutils/32967 * archive.c (_bfd_compute_and_write_armap): Call bfd_lto_slim_symbol_p to check LTO slim symbol. * bfd-in2.h: Generated. * bfd.c (bfd_lto_slim_symbol_p): New. binutils/ PR binutils/32967 * nm.c (filter_symbols): Call bfd_lto_slim_symbol_p to check LTO slim symbol. ld/ PR binutils/32967 * testsuite/ld-plugin/lto-binutils.exp: Run PR binutils/32967 tests. * testsuite/ld-plugin/strip-1a-s-all.nd: New file. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
@@ -2399,12 +2399,8 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
|
||||
map = new_map;
|
||||
}
|
||||
|
||||
if (syms[src_count]->name != NULL
|
||||
&& syms[src_count]->name[0] == '_'
|
||||
&& syms[src_count]->name[1] == '_'
|
||||
&& strcmp (syms[src_count]->name
|
||||
+ (syms[src_count]->name[2] == '_'),
|
||||
"__gnu_lto_slim") == 0
|
||||
if (bfd_lto_slim_symbol_p (current,
|
||||
syms[src_count]->name)
|
||||
&& report_plugin_err)
|
||||
{
|
||||
report_plugin_err = false;
|
||||
|
||||
@@ -2302,6 +2302,16 @@ bfd_get_lto_type (const bfd *abfd)
|
||||
return abfd->lto_type;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
bfd_lto_slim_symbol_p (const bfd *abfd, const char *name)
|
||||
{
|
||||
return (bfd_get_lto_type (abfd) != lto_non_ir_object
|
||||
&& name != NULL
|
||||
&& name[0] == '_'
|
||||
&& name[1] == '_'
|
||||
&& strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0);
|
||||
}
|
||||
|
||||
static inline flagword
|
||||
bfd_get_file_flags (const bfd *abfd)
|
||||
{
|
||||
|
||||
10
bfd/bfd.c
10
bfd/bfd.c
@@ -470,6 +470,16 @@ EXTERNAL
|
||||
. return abfd->lto_type;
|
||||
.}
|
||||
.
|
||||
.static inline bool
|
||||
.bfd_lto_slim_symbol_p (const bfd *abfd, const char *name)
|
||||
.{
|
||||
. return (bfd_get_lto_type (abfd) != lto_non_ir_object
|
||||
. && name != NULL
|
||||
. && name[0] == '_'
|
||||
. && name[1] == '_'
|
||||
. && strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0);
|
||||
.}
|
||||
.
|
||||
.static inline flagword
|
||||
.bfd_get_file_flags (const bfd *abfd)
|
||||
.{
|
||||
|
||||
@@ -801,10 +801,7 @@ filter_symbols (bfd *abfd, bool is_dynamic, void *minisyms,
|
||||
if (sym == NULL)
|
||||
continue;
|
||||
|
||||
if (sym->name != NULL
|
||||
&& sym->name[0] == '_'
|
||||
&& sym->name[1] == '_'
|
||||
&& strcmp (sym->name + (sym->name[2] == '_'), "__gnu_lto_slim") == 0
|
||||
if (bfd_lto_slim_symbol_p (abfd, sym->name)
|
||||
&& report_plugin_err)
|
||||
{
|
||||
report_plugin_err = false;
|
||||
|
||||
@@ -255,6 +255,25 @@ run_lto_binutils_test [list \
|
||||
] \
|
||||
]
|
||||
|
||||
if { [check_lto_fat_available] } {
|
||||
run_lto_binutils_test [list \
|
||||
[list \
|
||||
"strip" \
|
||||
"-R .gnu.*lto_* -N __gnu_lto_v1" \
|
||||
"strip-1a.o" \
|
||||
"strip-1a-s-all.o" \
|
||||
{{nm -n strip-1a-s-all.nd}} \
|
||||
] \
|
||||
[list \
|
||||
"strip" \
|
||||
"-R .gnu.*lto_* -N __gnu_lto_v1" \
|
||||
"libstrip-1a.a" \
|
||||
"libstrip-1a-s-all.a" \
|
||||
{{nm -n strip-1a-s-all.nd}} \
|
||||
] \
|
||||
]
|
||||
}
|
||||
|
||||
run_cc_link_tests [list \
|
||||
[list \
|
||||
"Build strip-1a (strip-1a.o)" \
|
||||
|
||||
3
ld/testsuite/ld-plugin/strip-1a-s-all.nd
Normal file
3
ld/testsuite/ld-plugin/strip-1a-s-all.nd
Normal file
@@ -0,0 +1,3 @@
|
||||
#...
|
||||
[0-9a-f]* C _?__gnu_lto_slim
|
||||
#pass
|
||||
Reference in New Issue
Block a user