[PATCH] Fix handling of PROVIDE_HIDDEN symbols

Khem Raj kraj@mvista.com
Thu Dec 8 17:43:00 GMT 2005



Lu, Hongjiu said the following on 12/06/2005 01:26 PM:
> Hi Thiemo,
>
> Sorry for that. The patch looks fine. But bfd-in2.h is a generated file.
> Does this patch work for you?
>   
I tested it locally and it works fine for me.
>
> H.J. Lu
> Intel Corporation
>
>
>   
>> -----Original Message-----
>> From: Thiemo Seufer [mailto:ths@networkno.de]
>> Sent: Monday, December 05, 2005 7:08 PM
>> To: binutils@sourceware.org
>> Cc: Lu, Hongjiu; Khem Raj
>> Subject: [PATCH] Fix handling of PROVIDE_HIDDEN symbols
>>
>> Hello All,
>>
>> the addition of PROVIDE_HIDDEN support by H.J. in 2005-08-05 causes
>> several failures for the mips toolchain, most notably for static
>> linking of mips-linux executables, but also PR ld/1932.
>>
>> This is caused by calling bfd_hide_symbol after the section sizing
>> was done, which converts global GOT entries to local ones when it
>> is already too late. The sizing is done in
>> ld/emultempl/elf32.em:gld${EMULATION_NAME}_before_allocation.
>>
>> I suspect other elf32.em users are affected as well.
>>
>> The appended patch lets bfd_elf_record_link_assignment account for
>> provided hidden symbols.
>>
>>
>> Thiemo
>>
>>
>> 2005-12-06  Thiemo Seufer  <ths@networkno.de>
>>
>> 	[ bfd/ChangeLog ]
>> 	PR ld/1932
>> 	* bfd-in2.h (bfd_elf_record_link_assignment): Add output_bfd
>> 	and hidden arguments.
>> 	* elflink.c (bfd_elf_record_link_assignment): Handle hidden
>> 	symbols which were provided by a linker script.
>>
>> 	[ ld/ChangeLog ]
>> 	* emultempl/elf32.em (gld${EMULATION_NAME}_find_exp_assignment):
>> 	Adjust bfd_elf_record_link_assignment call.
>>
>>
>> Index: bfd/bfd-in2.h
>> ===================================================================
>> RCS file: /cvs/src/src/bfd/bfd-in2.h,v
>> retrieving revision 1.372
>> diff -u -p -r1.372 bfd-in2.h
>> --- bfd/bfd-in2.h	24 Nov 2005 06:02:08 -0000	1.372
>> +++ bfd/bfd-in2.h	6 Dec 2005 02:40:35 -0000
>> @@ -640,7 +640,7 @@ enum dynamic_lib_link_class {
>> };
>>
>> extern bfd_boolean bfd_elf_record_link_assignment
>> -  (struct bfd_link_info *, const char *, bfd_boolean);
>> +  (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
>> bfd_boolean);
>> extern struct bfd_link_needed_list *bfd_elf_get_needed_list
>>   (bfd *, struct bfd_link_info *);
>> extern bfd_boolean bfd_elf_get_bfd_needed_list
>> Index: bfd/elflink.c
>> ===================================================================
>> RCS file: /cvs/src/src/bfd/elflink.c,v
>> retrieving revision 1.197
>> diff -u -p -r1.197 elflink.c
>> --- bfd/elflink.c	3 Nov 2005 02:53:38 -0000	1.197
>> +++ bfd/elflink.c	6 Dec 2005 02:40:36 -0000
>> @@ -424,9 +424,11 @@ bfd_elf_link_record_dynamic_symbol (stru
>>    this in case some dynamic object refers to this symbol.  */
>>
>> bfd_boolean
>> -bfd_elf_record_link_assignment (struct bfd_link_info *info,
>> +bfd_elf_record_link_assignment (bfd *output_bfd,
>> +				struct bfd_link_info *info,
>> 				const char *name,
>> -				bfd_boolean provide)
>> +				bfd_boolean provide,
>> +				bfd_boolean hidden)
>> {
>>   struct elf_link_hash_entry *h;
>>   struct elf_link_hash_table *htab;
>> @@ -473,6 +475,14 @@ bfd_elf_record_link_assignment (struct b
>>
>>   h->def_regular = 1;
>>
>> +  if (provide && hidden)
>> +    {
>> +      const struct elf_backend_data *bed = get_elf_backend_data
>> (output_bfd);
>> +
>> +      h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
>> +      (*bed->elf_backend_hide_symbol) (info, h, TRUE);
>> +    }
>> +
>>   /* STV_HIDDEN and STV_INTERNAL symbols must be STB_LOCAL in shared
>> objects
>>      and executables.  */
>>   if (!info->relocatable
>> Index: ld/emultempl/elf32.em
>> ===================================================================
>> RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
>> retrieving revision 1.160
>> diff -u -p -r1.160 elf32.em
>> --- ld/emultempl/elf32.em	24 Nov 2005 06:02:08 -0000	1.160
>> +++ ld/emultempl/elf32.em	6 Dec 2005 02:40:39 -0000
>> @@ -986,8 +986,9 @@ gld${EMULATION_NAME}_find_exp_assignment
>> 	 will do no harm.  */
>>       if (strcmp (exp->assign.dst, ".") != 0)
>> 	{
>> -	  if (!bfd_elf_record_link_assignment (&link_info, exp-
>>     
>>> assign.dst,
>>>       
>> -					       provide))
>> +	  if (!bfd_elf_record_link_assignment (output_bfd, &link_info,
>> +					       exp->assign.dst, provide,
>> +					       exp->assign.hidden))
>> 	    einfo ("%P%F: failed to record assignment to %s: %E\n",
>> 		   exp->assign.dst);
>> 	}
>>     



More information about the Binutils mailing list