* Re: stripping symbols needed for relocations
[not found] <s16e439a.026@emea1-mh.id2.novell.com>
@ 2004-10-18 14:19 ` Nick Clifton
0 siblings, 0 replies; 9+ messages in thread
From: Nick Clifton @ 2004-10-18 14:19 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
Hi Jan,
> The --strip-all case is out of question, but my concern is primarily
> with the combination of --strip-symbol/--strip-symbols and -w, but to
> some degree also with the plain use of --strip-symbol/--strip-symbols:
> When trying to cut down the number of symbols in the linux kernel
> (subject to kallsyms lookup) I'm trying to eliminate all non-text
> symbols. Finding them is not a problem, but filtering out those used in
> relocations is, which is why I'd want objcopy to do this for me. Since
> I'm of the general opinion that --strip-symbol for symbols used in
> relocations for non-discarded sections (which I would hope already don't
> get the BSF_KEEP flag set) will result in a broken output file, I'd like
> to make objcopy smart enough to deal with that situation (possibly
> through a new option --keep-needed or --force-strip-needed, depending on
> what the desirable default would be and whether keeping the current
> behavior is a requirement).
OK - I see your point. My original thinking was that if the user had
specified --strip-symbol=foo on the objcopy command line then that meant
that they definitely wanted "foo" stripped out, even if it was used in a
reloc, and that they knew what they were doing.
Given that we are dealing with the binutils here, where you are allowed
to shoot yourself in the foot if you do not know what you are doing, I
think that this behaviour of the --strip-symbol switch should be
retained. I would have no objections however to a patch which added
another switch, say --strip-unused-symbol=<>, or indeed the
--keep-needed switch you suggested, in order to provide a safer
environment for stripping symbols.
Cheers
Nick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: stripping symbols needed for relocations
2004-12-16 13:18 Jan Beulich
2004-12-16 14:20 ` Dave Korn
@ 2004-12-16 15:48 ` Nick Clifton
1 sibling, 0 replies; 9+ messages in thread
From: Nick Clifton @ 2004-12-16 15:48 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
Hi Jan,
>> * Please consider creating a new test in the binutils testsuite to
>> check the behaviour of this feature.
> Not done, primarily because none of the other --strip options seem to
> be tested.
You could start a trend for creating these tests...
Cheers
Nick
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: stripping symbols needed for relocations
2004-12-16 13:18 Jan Beulich
@ 2004-12-16 14:20 ` Dave Korn
2004-12-16 15:48 ` Nick Clifton
1 sibling, 0 replies; 9+ messages in thread
From: Dave Korn @ 2004-12-16 14:20 UTC (permalink / raw)
To: 'Jan Beulich', nickc; +Cc: binutils
> -----Original Message-----
> From: binutils-owner On Behalf Of Jan Beulich
> Sent: 16 December 2004 13:19
> > * Please consider creating a new test in the binutils testsuite to
>
> >check the behaviour of this feature.
>
> Not done, primarily because none of the other --strip options seem to
> be tested.
That seems a fairly dubious line of reasoning to me.
cheers,
DaveK
--
Can't think of a witty .sigline today....
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: stripping symbols needed for relocations
@ 2004-12-16 13:18 Jan Beulich
2004-12-16 14:20 ` Dave Korn
2004-12-16 15:48 ` Nick Clifton
0 siblings, 2 replies; 9+ messages in thread
From: Jan Beulich @ 2004-12-16 13:18 UTC (permalink / raw)
To: nickc; +Cc: binutils
>> binutils/
>> 2004-12-15 Jan Beulich <jbeulich@novell.com>
>>
>> * doc/binutils.texi: Document --strip-unneeded-symbol and
>> --strip-unneeded-symbols.
>> * objcopy.c (strip_unneeded_list): New.
>> (enum command_line_switch): Add OPTION_STRIP_UNNEEDED_SYMBOL
>> and OPTION_STRIP_UNNEEDED_SYMBOLS.
>> (copy_options): Add --strip-unneeded-symbol and
>> --strip-unneeded-symbols.
>> (copy_usage): Likewise.
>> (filter_symbols): Suppress copying of symbol if in
>> strip_unneeded_list
>> and the symbol is not needed.
>> (copy_main): Handle OPTION_STRIP_UNNEEDED_SYMBOL and
>> OPTION_STRIP_UNNEEDED_SYMBOLS.
>
>Approved - please apply, but ...
>
> * Please also add an entry to binutils/NEWS mentioning this new
feature.
Done.
> * Please consider creating a new test in the binutils testsuite to
>check the behaviour of this feature.
Not done, primarily because none of the other --strip options seem to
be tested.
Jan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: stripping symbols needed for relocations
2004-12-15 15:51 Jan Beulich
@ 2004-12-16 12:07 ` Nick Clifton
0 siblings, 0 replies; 9+ messages in thread
From: Nick Clifton @ 2004-12-16 12:07 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
Hi Jan,
> binutils/
> 2004-12-15 Jan Beulich <jbeulich@novell.com>
>
> * doc/binutils.texi: Document --strip-unneeded-symbol and
> --strip-unneeded-symbols.
> * objcopy.c (strip_unneeded_list): New.
> (enum command_line_switch): Add OPTION_STRIP_UNNEEDED_SYMBOL
> and OPTION_STRIP_UNNEEDED_SYMBOLS.
> (copy_options): Add --strip-unneeded-symbol and
> --strip-unneeded-symbols.
> (copy_usage): Likewise.
> (filter_symbols): Suppress copying of symbol if in
> strip_unneeded_list
> and the symbol is not needed.
> (copy_main): Handle OPTION_STRIP_UNNEEDED_SYMBOL and
> OPTION_STRIP_UNNEEDED_SYMBOLS.
Approved - please apply, but ...
* Please also add an entry to binutils/NEWS mentioning this new feature.
* Please consider creating a new test in the binutils testsuite to
check the behaviour of this feature.
Cheers
Nick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: stripping symbols needed for relocations
@ 2004-12-15 15:51 Jan Beulich
2004-12-16 12:07 ` Nick Clifton
0 siblings, 1 reply; 9+ messages in thread
From: Jan Beulich @ 2004-12-15 15:51 UTC (permalink / raw)
To: nickc; +Cc: binutils
[-- Attachment #1: Type: text/plain, Size: 8613 bytes --]
>> The --strip-all case is out of question, but my concern is primarily
>> with the combination of --strip-symbol/--strip-symbols and -w, but
to
>> some degree also with the plain use of
--strip-symbol/--strip-symbols:
>> When trying to cut down the number of symbols in the linux kernel
>> (subject to kallsyms lookup) I'm trying to eliminate all non-text
>> symbols. Finding them is not a problem, but filtering out those used
in
>> relocations is, which is why I'd want objcopy to do this for me.
Since
>> I'm of the general opinion that --strip-symbol for symbols used in
>> relocations for non-discarded sections (which I would hope already
don't
>> get the BSF_KEEP flag set) will result in a broken output file, I'd
like
>> to make objcopy smart enough to deal with that situation (possibly
>> through a new option --keep-needed or --force-strip-needed,
depending on
>> what the desirable default would be and whether keeping the current
>> behavior is a requirement).
>
>OK - I see your point. My original thinking was that if the user had
>specified --strip-symbol=foo on the objcopy command line then that
meant
>that they definitely wanted "foo" stripped out, even if it was used in
a
>reloc, and that they knew what they were doing.
>
>Given that we are dealing with the binutils here, where you are
allowed
>to shoot yourself in the foot if you do not know what you are doing, I
>think that this behaviour of the --strip-symbol switch should be
>retained. I would have no objections however to a patch which added
>another switch, say --strip-unused-symbol=<>, or indeed the
>--keep-needed switch you suggested, in order to provide a safer
>environment for stripping symbols.
So I chose the more fine-grained method with
--strip-unneeded-symbol[s].
Built and tested on i686-pc-linux-gnu.
Jan
binutils/
2004-12-15 Jan Beulich <jbeulich@novell.com>
* doc/binutils.texi: Document --strip-unneeded-symbol and
--strip-unneeded-symbols.
* objcopy.c (strip_unneeded_list): New.
(enum command_line_switch): Add OPTION_STRIP_UNNEEDED_SYMBOL
and OPTION_STRIP_UNNEEDED_SYMBOLS.
(copy_options): Add --strip-unneeded-symbol and
--strip-unneeded-symbols.
(copy_usage): Likewise.
(filter_symbols): Suppress copying of symbol if in
strip_unneeded_list
and the symbol is not needed.
(copy_main): Handle OPTION_STRIP_UNNEEDED_SYMBOL and
OPTION_STRIP_UNNEEDED_SYMBOLS.
---
/home/jbeulich/src/binutils/mainline/2004-12-03.13.35/binutils/doc/binutils.texi 2004-11-18
15:05:13.000000000 +0100
+++ 2004-12-03.13.35/binutils/doc/binutils.texi 2004-12-15
16:35:20.514605416 +0100
@@ -947,6 +947,7 @@ objcopy [@option{-F} @var{bfdname}|@opti
[@option{-g}|@option{--strip-debug}]
[@option{-K}
@var{symbolname}|@option{--keep-symbol=}@var{symbolname}]
[@option{-N}
@var{symbolname}|@option{--strip-symbol=}@var{symbolname}]
+ [@option{--strip-unneeded-symbol=}@var{symbolname}]
[@option{-G}
@var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}]
[@option{-L}
@var{symbolname}|@option{--localize-symbol=}@var{symbolname}]
[@option{-W}
@var{symbolname}|@option{--weaken-symbol=}@var{symbolname}]
@@ -978,6 +979,7 @@ objcopy [@option{-F} @var{bfdname}|@opti
[@option{--weaken}]
[@option{--keep-symbols=}@var{filename}]
[@option{--strip-symbols=}@var{filename}]
+ [@option{--strip-unneeded-symbols=}@var{filename}]
[@option{--keep-global-symbols=}@var{filename}]
[@option{--localize-symbols=}@var{filename}]
[@option{--weaken-symbols=}@var{filename}]
@@ -1106,6 +1108,10 @@ be given more than once.
Do not copy symbol @var{symbolname} from the source file. This
option
may be given more than once.
+@item --strip-unneeded-symbol=@var{symbolname}
+Do not copy symbol @var{symbolname} from the source file unless it is
needed
+by a relocation. This option may be given more than once.
+
@item -G @var{symbolname}
@itemx --keep-global-symbol=@var{symbolname}
Keep only symbol @var{symbolname} global. Make all other symbols
local
@@ -1347,6 +1353,12 @@ Apply @option{--strip-symbol} option to
name per line. Line comments may be introduced by the hash
character.
This option may be given more than once.
+@item --strip-unneeded-symbols=@var{filename}
+Apply @option{--strip-unneeded-symbol} option to each symbol listed
in
+the file @var{filename}. @var{filename} is simply a flat file, with
one
+symbol name per line. Line comments may be introduced by the hash
+character. This option may be given more than once.
+
@item --keep-global-symbols=@var{filename}
Apply @option{--keep-global-symbol} option to each symbol listed in
the
file @var{filename}. @var{filename} is simply a flat file, with one
---
/home/jbeulich/src/binutils/mainline/2004-12-03.13.35/binutils/objcopy.c 2004-11-02
17:16:02.000000000 +0100
+++ 2004-12-03.13.35/binutils/objcopy.c 2004-12-15
16:26:32.097936960 +0100
@@ -192,6 +192,7 @@ static bfd_boolean wildcard = FALSE;
/* List of symbols to strip, keep, localize, keep-global, weaken,
or redefine. */
static struct symlist *strip_specific_list = NULL;
+static struct symlist *strip_unneeded_list = NULL;
static struct symlist *keep_specific_list = NULL;
static struct symlist *localize_specific_list = NULL;
static struct symlist *keepglobal_specific_list = NULL;
@@ -231,6 +232,8 @@ enum command_line_switch
OPTION_SREC_LEN,
OPTION_SREC_FORCES3,
OPTION_STRIP_SYMBOLS,
+ OPTION_STRIP_UNNEEDED_SYMBOL,
+ OPTION_STRIP_UNNEEDED_SYMBOLS,
OPTION_KEEP_SYMBOLS,
OPTION_LOCALIZE_SYMBOLS,
OPTION_KEEPGLOBAL_SYMBOLS,
@@ -340,6 +343,8 @@ static struct option copy_options[] =
{"strip-all", no_argument, 0, 'S'},
{"strip-debug", no_argument, 0, 'g'},
{"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED},
+ {"strip-unneeded-symbol", required_argument, 0,
OPTION_STRIP_UNNEEDED_SYMBOL},
+ {"strip-unneeded-symbols", required_argument, 0,
OPTION_STRIP_UNNEEDED_SYMBOLS},
{"strip-symbol", required_argument, 0, 'N'},
{"strip-symbols", required_argument, 0, OPTION_STRIP_SYMBOLS},
{"target", required_argument, 0, 'F'},
@@ -405,6 +410,9 @@ copy_usage (FILE *stream, int exit_statu
-g --strip-debug Remove all debugging symbols &
sections\n\
--strip-unneeded Remove all symbols not needed by
relocations\n\
-N --strip-symbol <name> Do not copy symbol <name>\n\
+ --strip-unneeded-symbol <name>\n\
+ Do not copy symbol <name> unless
needed by\n\
+ relocations\n\
--only-keep-debug Strip everything but the debug
information\n\
-K --keep-symbol <name> Only copy symbol <name>\n\
-L --localize-symbol <name> Force symbol <name> to be marked as
a local\n\
@@ -443,6 +451,9 @@ copy_usage (FILE *stream, int exit_statu
--srec-len <number> Restrict the length of generated
Srecords\n\
--srec-forceS3 Restrict the type of generated
Srecords to S3\n\
--strip-symbols <file> -N for all symbols listed in
<file>\n\
+ --strip-unneeded-symbols <file>\n\
+ --strip-unneeded-symbol for all
symbols listed\n\
+ in <file>\n\
--keep-symbols <file> -K for all symbols listed in
<file>\n\
--localize-symbols <file> -L for all symbols listed in
<file>\n\
--keep-global-symbols <file> -G for all symbols listed in
<file>\n\
@@ -903,6 +914,10 @@ filter_symbols (bfd *abfd, bfd *obfd, as
if (keep && is_specified_symbol (name, strip_specific_list))
keep = 0;
+ if (keep
+ && !(flags & BSF_KEEP)
+ && is_specified_symbol (name, strip_unneeded_list))
+ keep = 0;
if (!keep && is_specified_symbol (name, keep_specific_list))
keep = 1;
if (keep && is_strip_section (abfd, bfd_get_section (sym)))
@@ -2525,6 +2540,10 @@ copy_main (int argc, char *argv[])
add_specific_symbol (optarg, &strip_specific_list);
break;
+ case OPTION_STRIP_UNNEEDED_SYMBOL:
+ add_specific_symbol (optarg, &strip_unneeded_list);
+ break;
+
case 'L':
add_specific_symbol (optarg, &localize_specific_list);
break;
@@ -2858,6 +2877,10 @@ copy_main (int argc, char *argv[])
add_specific_symbols (optarg, &strip_specific_list);
break;
+ case OPTION_STRIP_UNNEEDED_SYMBOLS:
+ add_specific_symbols (optarg, &strip_unneeded_list);
+ break;
+
case OPTION_KEEP_SYMBOLS:
add_specific_symbols (optarg, &keep_specific_list);
break;
[-- Attachment #2: binutils-mainline-strip-unneeded-symbols.patch --]
[-- Type: application/octet-stream, Size: 6911 bytes --]
So I chose the more fine-grained method with --strip-unneeded-symbol[s].
Built and tested on i686-pc-linux-gnu.
Jan
binutils/
2004-12-15 Jan Beulich <jbeulich@novell.com>
* doc/binutils.texi: Document --strip-unneeded-symbol and
--strip-unneeded-symbols.
* objcopy.c (strip_unneeded_list): New.
(enum command_line_switch): Add OPTION_STRIP_UNNEEDED_SYMBOL
and OPTION_STRIP_UNNEEDED_SYMBOLS.
(copy_options): Add --strip-unneeded-symbol and
--strip-unneeded-symbols.
(copy_usage): Likewise.
(filter_symbols): Suppress copying of symbol if in strip_unneeded_list
and the symbol is not needed.
(copy_main): Handle OPTION_STRIP_UNNEEDED_SYMBOL and
OPTION_STRIP_UNNEEDED_SYMBOLS.
--- /home/jbeulich/src/binutils/mainline/2004-12-03.13.35/binutils/doc/binutils.texi 2004-11-18 15:05:13.000000000 +0100
+++ 2004-12-03.13.35/binutils/doc/binutils.texi 2004-12-15 16:35:20.514605416 +0100
@@ -947,6 +947,7 @@ objcopy [@option{-F} @var{bfdname}|@opti
[@option{-g}|@option{--strip-debug}]
[@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}]
[@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}]
+ [@option{--strip-unneeded-symbol=}@var{symbolname}]
[@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}]
[@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}]
[@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}]
@@ -978,6 +979,7 @@ objcopy [@option{-F} @var{bfdname}|@opti
[@option{--weaken}]
[@option{--keep-symbols=}@var{filename}]
[@option{--strip-symbols=}@var{filename}]
+ [@option{--strip-unneeded-symbols=}@var{filename}]
[@option{--keep-global-symbols=}@var{filename}]
[@option{--localize-symbols=}@var{filename}]
[@option{--weaken-symbols=}@var{filename}]
@@ -1106,6 +1108,10 @@ be given more than once.
Do not copy symbol @var{symbolname} from the source file. This option
may be given more than once.
+@item --strip-unneeded-symbol=@var{symbolname}
+Do not copy symbol @var{symbolname} from the source file unless it is needed
+by a relocation. This option may be given more than once.
+
@item -G @var{symbolname}
@itemx --keep-global-symbol=@var{symbolname}
Keep only symbol @var{symbolname} global. Make all other symbols local
@@ -1347,6 +1353,12 @@ Apply @option{--strip-symbol} option to
name per line. Line comments may be introduced by the hash character.
This option may be given more than once.
+@item --strip-unneeded-symbols=@var{filename}
+Apply @option{--strip-unneeded-symbol} option to each symbol listed in
+the file @var{filename}. @var{filename} is simply a flat file, with one
+symbol name per line. Line comments may be introduced by the hash
+character. This option may be given more than once.
+
@item --keep-global-symbols=@var{filename}
Apply @option{--keep-global-symbol} option to each symbol listed in the
file @var{filename}. @var{filename} is simply a flat file, with one
--- /home/jbeulich/src/binutils/mainline/2004-12-03.13.35/binutils/objcopy.c 2004-11-02 17:16:02.000000000 +0100
+++ 2004-12-03.13.35/binutils/objcopy.c 2004-12-15 16:26:32.097936960 +0100
@@ -192,6 +192,7 @@ static bfd_boolean wildcard = FALSE;
/* List of symbols to strip, keep, localize, keep-global, weaken,
or redefine. */
static struct symlist *strip_specific_list = NULL;
+static struct symlist *strip_unneeded_list = NULL;
static struct symlist *keep_specific_list = NULL;
static struct symlist *localize_specific_list = NULL;
static struct symlist *keepglobal_specific_list = NULL;
@@ -231,6 +232,8 @@ enum command_line_switch
OPTION_SREC_LEN,
OPTION_SREC_FORCES3,
OPTION_STRIP_SYMBOLS,
+ OPTION_STRIP_UNNEEDED_SYMBOL,
+ OPTION_STRIP_UNNEEDED_SYMBOLS,
OPTION_KEEP_SYMBOLS,
OPTION_LOCALIZE_SYMBOLS,
OPTION_KEEPGLOBAL_SYMBOLS,
@@ -340,6 +343,8 @@ static struct option copy_options[] =
{"strip-all", no_argument, 0, 'S'},
{"strip-debug", no_argument, 0, 'g'},
{"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED},
+ {"strip-unneeded-symbol", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOL},
+ {"strip-unneeded-symbols", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOLS},
{"strip-symbol", required_argument, 0, 'N'},
{"strip-symbols", required_argument, 0, OPTION_STRIP_SYMBOLS},
{"target", required_argument, 0, 'F'},
@@ -405,6 +410,9 @@ copy_usage (FILE *stream, int exit_statu
-g --strip-debug Remove all debugging symbols & sections\n\
--strip-unneeded Remove all symbols not needed by relocations\n\
-N --strip-symbol <name> Do not copy symbol <name>\n\
+ --strip-unneeded-symbol <name>\n\
+ Do not copy symbol <name> unless needed by\n\
+ relocations\n\
--only-keep-debug Strip everything but the debug information\n\
-K --keep-symbol <name> Only copy symbol <name>\n\
-L --localize-symbol <name> Force symbol <name> to be marked as a local\n\
@@ -443,6 +451,9 @@ copy_usage (FILE *stream, int exit_statu
--srec-len <number> Restrict the length of generated Srecords\n\
--srec-forceS3 Restrict the type of generated Srecords to S3\n\
--strip-symbols <file> -N for all symbols listed in <file>\n\
+ --strip-unneeded-symbols <file>\n\
+ --strip-unneeded-symbol for all symbols listed\n\
+ in <file>\n\
--keep-symbols <file> -K for all symbols listed in <file>\n\
--localize-symbols <file> -L for all symbols listed in <file>\n\
--keep-global-symbols <file> -G for all symbols listed in <file>\n\
@@ -903,6 +914,10 @@ filter_symbols (bfd *abfd, bfd *obfd, as
if (keep && is_specified_symbol (name, strip_specific_list))
keep = 0;
+ if (keep
+ && !(flags & BSF_KEEP)
+ && is_specified_symbol (name, strip_unneeded_list))
+ keep = 0;
if (!keep && is_specified_symbol (name, keep_specific_list))
keep = 1;
if (keep && is_strip_section (abfd, bfd_get_section (sym)))
@@ -2525,6 +2540,10 @@ copy_main (int argc, char *argv[])
add_specific_symbol (optarg, &strip_specific_list);
break;
+ case OPTION_STRIP_UNNEEDED_SYMBOL:
+ add_specific_symbol (optarg, &strip_unneeded_list);
+ break;
+
case 'L':
add_specific_symbol (optarg, &localize_specific_list);
break;
@@ -2858,6 +2877,10 @@ copy_main (int argc, char *argv[])
add_specific_symbols (optarg, &strip_specific_list);
break;
+ case OPTION_STRIP_UNNEEDED_SYMBOLS:
+ add_specific_symbols (optarg, &strip_unneeded_list);
+ break;
+
case OPTION_KEEP_SYMBOLS:
add_specific_symbols (optarg, &keep_specific_list);
break;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: stripping symbols needed for relocations
@ 2004-10-14 8:15 Jan Beulich
0 siblings, 0 replies; 9+ messages in thread
From: Jan Beulich @ 2004-10-14 8:15 UTC (permalink / raw)
To: nickc; +Cc: binutils
Nick,
>> Wouldn't it make sense to prevent doing such (except when
--strip-all)
>> in the first place (binutils/objcopy.c, filter_symbols) rather than
>> generating an error message (bfd/elf.c,
>> _bfd_elf_symbol_from_bfd_symbol)? Or are there specific uses of
doing so
>> that would not result in such an error?
>
>I think that the only case where it would not matter is if the
>relocation is in a section which is going to be discarded. So to
answer
>your first question, yes I think that filter_symbols() should try to
>preserve reloc-used symbols unless --strip-all or --strip-symbol is in
>effect. Note that the code does already try to do this by looking for
>the BSF_KEEP flag.
The --strip-all case is out of question, but my concern is primarily
with the combination of --strip-symbol/--strip-symbols and -w, but to
some degree also with the plain use of --strip-symbol/--strip-symbols:
When trying to cut down the number of symbols in the linux kernel
(subject to kallsyms lookup) I'm trying to eliminate all non-text
symbols. Finding them is not a problem, but filtering out those used in
relocations is, which is why I'd want objcopy to do this for me. Since
I'm of the general opinion that --strip-symbol for symbols used in
relocations for non-discarded sections (which I would hope already don't
get the BSF_KEEP flag set) will result in a broken output file, I'd like
to make objcopy smart enough to deal with that situation (possibly
through a new option --keep-needed or --force-strip-needed, depending on
what the desirable default would be and whether keeping the current
behavior is a requirement).
Jan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: stripping symbols needed for relocations
2004-10-11 11:48 Jan Beulich
@ 2004-10-13 15:57 ` Nick Clifton
0 siblings, 0 replies; 9+ messages in thread
From: Nick Clifton @ 2004-10-13 15:57 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
Hi Jan,
> Wouldn't it make sense to prevent doing such (except when --strip-all)
> in the first place (binutils/objcopy.c, filter_symbols) rather than
> generating an error message (bfd/elf.c,
> _bfd_elf_symbol_from_bfd_symbol)? Or are there specific uses of doing so
> that would not result in such an error?
I think that the only case where it would not matter is if the
relocation is in a section which is going to be discarded. So to answer
your first question, yes I think that filter_symbols() should try to
preserve reloc-used symbols unless --strip-all or --strip-symbol is in
effect. Note that the code does already try to do this by looking for
the BSF_KEEP flag.
Cheers
Nick
^ permalink raw reply [flat|nested] 9+ messages in thread
* stripping symbols needed for relocations
@ 2004-10-11 11:48 Jan Beulich
2004-10-13 15:57 ` Nick Clifton
0 siblings, 1 reply; 9+ messages in thread
From: Jan Beulich @ 2004-10-11 11:48 UTC (permalink / raw)
To: binutils
Wouldn't it make sense to prevent doing such (except when --strip-all)
in the first place (binutils/objcopy.c, filter_symbols) rather than
generating an error message (bfd/elf.c,
_bfd_elf_symbol_from_bfd_symbol)? Or are there specific uses of doing so
that would not result in such an error?
Thanks, Jan
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-12-16 15:48 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <s16e439a.026@emea1-mh.id2.novell.com>
2004-10-18 14:19 ` stripping symbols needed for relocations Nick Clifton
2004-12-16 13:18 Jan Beulich
2004-12-16 14:20 ` Dave Korn
2004-12-16 15:48 ` Nick Clifton
-- strict thread matches above, loose matches on Subject: below --
2004-12-15 15:51 Jan Beulich
2004-12-16 12:07 ` Nick Clifton
2004-10-14 8:15 Jan Beulich
2004-10-11 11:48 Jan Beulich
2004-10-13 15:57 ` Nick Clifton
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).