[Bug lto/86517] relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object with LTO

hubicka at ucw dot cz gcc-bugzilla@gcc.gnu.org
Mon Jul 16 08:13:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86517

--- Comment #6 from Jan Hubicka <hubicka at ucw dot cz> ---
The problem is logic in lto-wrapper (which is mine)
  /* Merge PIC options:                                                         
      -fPIC + -fpic = -fpic                                                     
      -fPIC + -fno-pic = -fno-pic                                               
      -fpic/-fPIC + nothin = nothing.                                           
     It is a common mistake to mix few -fPIC compiled objects into otherwise    
     non-PIC code.  We do not want to build everything with PIC then.           

     It would be good to warn on mismatches, but it is bit hard to do as        
     we do not know what nothing translates to.  */                             

  for (unsigned int j = 0; j < *decoded_options_count;)                         
    if ((*decoded_options)[j].opt_index == OPT_fPIC                             
        || (*decoded_options)[j].opt_index == OPT_fpic)                         
      {                                                                         
        if (!pic_option                                                         
            || (pic_option->value > 0) != ((*decoded_options)[j].value > 0))    
          remove_option (decoded_options, j, decoded_options_count);            
        else if (pic_option->opt_index == OPT_fPIC                              
                 && (*decoded_options)[j].opt_index == OPT_fpic)                
          {                                                                     
            (*decoded_options)[j] = *pic_option;                                
            j++;                                                                
          }                                                                     
        else                                                                    
          j++;                                                                  
      }                                                                         
   else if ((*decoded_options)[j].opt_index == OPT_fPIE                         
            || (*decoded_options)[j].opt_index == OPT_fpie)                     
      {                                                                         
        if (!pie_option                                                         
            || pie_option->value != (*decoded_options)[j].value)                
          remove_option (decoded_options, j, decoded_options_count);            
        else if (pie_option->opt_index == OPT_fPIE                              
                 && (*decoded_options)[j].opt_index == OPT_fpie)                
          {                                                                     
            (*decoded_options)[j] = *pie_option;                                
            j++;                                                                
          }                                                                     
        else                                                                    
          j++;                                                                  
      }                                                                         

PIC merging is OK, but PIE merging should not remove PIE if PIC is provided in
other units.
I am looking into fix.

Honza


More information about the Gcc-bugs mailing list