This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Thanks for reviewing. Here is an updated patch.
2009-06-05 Doug Kwan <dougkwan@google.com>
* Makefile.am (CCFILES): Add target.cc.
* Makefile.in: Regenerate.
* i386.cc (class Target_i386): Define new virtual method to
override do_is_local_label_name in parent.
* object.cc (Sized_relobj::do_count_local_symbols): Discard
local symbols if --discard-locals or -X is given.
* options.h (class General_options): Declare new options
'--discard-locals' and '-X' for discarding locals.
* target.h (class Target): Define new methods is_local_label_name.
Declare new virtual method do_is_local_label_name.
* target.cc: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add discard_locals_test.
(check_SCRIPTS): Add discard_locals_test.sh.
(check_DATA): Add discard_local_tests.syms.
(discard_locals_test_SOURCES, discard_locals_test_LDFLAGS): Define.
(discard_local_tests.syms, discard_locals_test.o): New make rules.
* testsuite/Makefile.in: Regenerate.
* testsuite/discard_locals_test.c: New file.
* testsuite/discard_locals_test.sh: Same.
-Doug
2009/6/5 Ian Lance Taylor <iant@google.com>:
> "Doug Kwan (Ãö®¶¼w)" <dougkwan@google.com> writes:
>
>> const char* name = pnames + sym.get_st_name();
>> + if (discard_locals
>> + && sym.get_st_type() != elfcpp::STT_FILE
>> + && parameters->target().is_local_label_name(name))
>> + {
>> + lv.set_no_output_symtab_entry();
>> + gold_assert(!lv.needs_output_dynsym_entry());
>> + continue;
>> + }
>
> Instead of asserting, don't discard the symbol if
> lv.needs_output_dynsym_entry() returns true.
>
>> + // Virtual function which may be overriden by the child class.
>> + virtual bool
>> + do_is_local_label_name(const char* name) const
>> + {
>> + // The logic is the same as that in _bfd_elf_is_local_label_name().
>> +
>> + // Normal local symbols start with ``.L''.
>> + if (name[0] == '.' && name[1] == 'L')
>> + return true;
>> +
>> + // At least some SVR4 compilers (e.g., UnixWare 2.1 cc) generate
>> + // DWARF debugging symbols starting with ``..''.
>> + if (name[0] == '.' && name[1] == '.')
>> + return true;
>> +
>> + // gcc will sometimes generate symbols beginning with ``_.L_'' when
>> + // emitting DWARF debugging output. I suspect this is actually a
>> + // small bug in gcc (it calls ASM_OUTPUT_LABEL when it should call
>> + // ASM_GENERATE_INTERNAL_LABEL, and this causes the leading
>> + // underscore to be emitted on some ELF targets). For ease of use,
>> + // we treat such symbols as local.
>> + if (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_')
>> + return true;
>> +
>> + return false;
>> + }
>
> This is too big to define inline in the class. Define it in target.h
> just below the class definition. Add a target.cc file and define it
> there.
>
>> +# '-Wa,--keep-locals' is required to preserve the local label used for testing.
>> +discard_locals_test.o: discard_locals_test.c
>> + $(COMPILE) -c -Wa,--keep-locals -o $@ $<
>
> s/--keep-locals/-L/g
>
>> +int
>> +main (void)
>> +{
>> + /* local symbol format for generic ELF target. */
>> + asm (".Lshould_be_discarded:");
>> +
>> +#ifdef __i386__
>> + /* additional local symbol format for the i386 target. */
>> + asm (".Xshould_be_discarded:");
>> +#endif
>> +
>> + return 0;
>> +}
>
> I think it would be better to put the asm statements outside of the main
> function.
>
> Please send another patch with these changes for final approval.
>
> Thanks.
>
> Ian
>
Attachment:
patch.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |