rel/rela patch for get_dynamic_reloc_section_name

Nick Clifton nickc@redhat.com
Tue Feb 22 15:39:00 GMT 2011


Hi H.J.

>> +  name = bfd_alloc (abfd, (is_rela ? 6 : 5) + strlen (old_name));
>> +  if (is_rela)
>> +    strcpy (name, ".rela");
>> +  else
>> +    strcpy (name, ".rel");
>> +  strcat (name, old_name);

>>   const char * prefix = is_rela ? ".rela" : ".rel";
>>   name = bfd_alloc (abfd, strlen (prefix) + strlen (old_name) + 1);
>>   sprintf (name, "%s%s", prefix, old_name);

> Why not just use (is_rela ? sizeof (.rela) -1: sizeof (.rel) - 1)

Because with that version you still have to type in the prefix strings 
twice, once for the sizeof computation and once for the string creation. 
  With my version the strings are only typed in once giving less chance 
for a typo and a clearer indication that the size of the name buffer is 
related to the strings that are being placed into it.

Cheers
   Nick




More information about the Binutils mailing list