[Bug target/16343] invalid code when using -meabi -msdata=eabi

a_fisch at gmx dot de gcc-bugzilla@gcc.gnu.org
Fri Nov 12 19:21:00 GMT 2004


------- Additional Comments From a_fisch at gmx dot de  2004-11-12 19:20 -------
The Bug is in gcc/config/rs6000/rs6000.c in function 
rs6000_elf_in_small_data_p() 
 
With gcc version 3.4.x? (2003-05-02) the macro SYMBOL_REF_SMALL_P () was 
introduced, which checks for a flag, which is not properly set, if the 
referenced symbol is a function.  
 
The flag is used in small_data_operand () but has to be set in  
rs6000_elf_in_small_data_p (). 
 
I compared the implementation of ??_in_small_data_p() for different cpu's 
(alpha, mips) and changed rs6000_elf_in_small_data_p () as follows: 
 
static bool 
rs6000_elf_in_small_data_p (tree decl) 
{ 
  if (rs6000_sdata == SDATA_NONE) 
    return false; 
 
/* --------- Begin of code to insert ---------- */ 
  /* We want to merge strings, so we never consider them small data. */ 
  if (TREE_CODE (decl) == STRING_CST) 
      return false; 
   
  /* Functions are never in the small data area. */ 
  if (TREE_CODE (decl) == FUNCTION_DECL) 
      return false; 
/* --------- End of code to insert ---------- */ 
   
  if (TREE_CODE (decl) == VAR_DECL && DECL_SECTION_NAME (decl)) 
    { 
      const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); 
      if (strcmp (section, ".sdata") == 0 
	  || strcmp (section, ".sdata2") == 0 
	  || strcmp (section, ".sbss") == 0 
	  || strcmp (section, ".sbss2") == 0 
	  || strcmp (section, ".PPC.EMB.sdata0") == 0 
	  || strcmp (section, ".PPC.EMB.sbss0") == 0) 
	return true; 
    } 
  else 
    { 
      HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl)); 
 
      if (size > 0 
	  && (unsigned HOST_WIDE_INT) size <= g_switch_value 
	  /* If it's not public, and we're not going to reference it there, 
	     there's no need to put it in the small data section.  */ 
	  && (rs6000_sdata != SDATA_DATA || TREE_PUBLIC (decl))) 
	return true; 
    } 
 
  return false; 
} 
 
I tested the changed code and the result is promising. As far as I know this 
error must have effected all powerpc-targets which use ELF and have small data 
areas (powerpc-elf, powerpc-eabi, ...) 
 
Because I'm not familiar with the process of generating patches and sending 
the result back to the mainline, I would like to ask one of you, watching this 
error to integerate it. 
   
 
 
 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |a_fisch at gmx dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16343



More information about the Gcc-bugs mailing list