#include "tm_p.h"
#include "debug.h"
#include "target.h"
+#include "common/common-target.h"
#include "targhooks.h"
#include "tree-mudflap.h"
#include "cgraph.h"
int flag_function_or_data_sections)
{
if (DECL_SECTION_NAME (decl) == NULL_TREE
- && targetm.have_named_sections
+ && targetm_common.have_named_sections
&& (flag_function_or_data_sections
|| DECL_ONE_ONLY (decl)))
{
{
if (decl != NULL_TREE
&& DECL_SECTION_NAME (decl) != NULL_TREE
- && targetm.have_named_sections)
+ && targetm_common.have_named_sections)
return get_named_section (decl, NULL, 0);
else
return text_section;
#endif
if (!flag_reorder_functions
- || !targetm.have_named_sections)
+ || !targetm_common.have_named_sections)
return NULL;
/* Startup code should go to startup subsection unless it is
unlikely executed (this happens especially with function splitting
const char *str;
HOST_WIDE_INT i;
int j, unit;
- char name[30];
+ const char *prefix = targetm.asm_out.mergeable_rodata_prefix;
+ char *name = (char *) alloca (strlen (prefix) + 30);
mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
modesize = GET_MODE_BITSIZE (mode);
}
if (i == len - unit)
{
- sprintf (name, ".rodata.str%d.%d", modesize / 8,
- (int) (align / 8));
+ sprintf (name, "%s.str%d.%d", prefix,
+ modesize / 8, (int) (align / 8));
flags |= (modesize / 8) | SECTION_MERGE | SECTION_STRINGS;
return get_section (name, flags, NULL);
}
&& align <= 256
&& (align & (align - 1)) == 0)
{
- char name[24];
+ const char *prefix = targetm.asm_out.mergeable_rodata_prefix;
+ char *name = (char *) alloca (strlen (prefix) + 30);
- sprintf (name, ".rodata.cst%d", (int) (align / 8));
+ sprintf (name, "%s.cst%d", prefix, (int) (align / 8));
flags |= (align / 8) | SECTION_MERGE;
return get_section (name, flags, NULL);
}
const char *name;
if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
- && DECL_FUNCTION_CODE (decl) == BUILT_IN_ALLOCA)
+ && (DECL_FUNCTION_CODE (decl) == BUILT_IN_ALLOCA
+ || DECL_FUNCTION_CODE (decl) == BUILT_IN_ALLOCA_WITH_ALIGN))
return true;
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
initial_trampoline = gen_const_mem (BLKmode, symbol);
set_mem_align (initial_trampoline, TRAMPOLINE_ALIGNMENT);
- set_mem_size (initial_trampoline, GEN_INT (TRAMPOLINE_SIZE));
+ set_mem_size (initial_trampoline, TRAMPOLINE_SIZE);
return initial_trampoline;
}
* tree_low_cst (TREE_OPERAND (target, 1), 0));
target = TREE_OPERAND (target, 0);
}
+ else if (TREE_CODE (target) == MEM_REF
+ && TREE_CODE (TREE_OPERAND (target, 0)) == ADDR_EXPR)
+ {
+ offset += mem_ref_offset (target).low;
+ target = TREE_OPERAND (TREE_OPERAND (target, 0), 0);
+ }
else if (TREE_CODE (target) == INDIRECT_REF
&& TREE_CODE (TREE_OPERAND (target, 0)) == NOP_EXPR
&& TREE_CODE (TREE_OPERAND (TREE_OPERAND (target, 0), 0))
SET_SYMBOL_REF_DECL (symbol, decl);
TREE_CONSTANT_POOL_ADDRESS_P (symbol) = 1;
- rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), symbol);
+ rtl = gen_const_mem (TYPE_MODE (TREE_TYPE (exp)), symbol);
set_mem_attributes (rtl, exp, 1);
set_mem_alias_set (rtl, 0);
set_mem_alias_set (rtl, const_alias_set);
static unsigned HOST_WIDE_INT
array_size_for_constructor (tree val)
{
- tree max_index, i;
+ tree max_index;
unsigned HOST_WIDE_INT cnt;
tree index, value, tmp;
+ double_int i;
/* This code used to attempt to handle string constants that are not
arrays of single-bytes, but nothing else does, so there's no point in
/* Compute the total number of array elements. */
tmp = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)));
- i = size_binop (MINUS_EXPR, fold_convert (sizetype, max_index),
- fold_convert (sizetype, tmp));
- i = size_binop (PLUS_EXPR, i, size_one_node);
+ i = double_int_sub (tree_to_double_int (max_index), tree_to_double_int (tmp));
+ i = double_int_add (i, double_int_one);
/* Multiply by the array element unit size to find number of bytes. */
- i = size_binop (MULT_EXPR, i, TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))));
+ i = double_int_mul (i, tree_to_double_int
+ (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val)))));
- return tree_low_cst (i, 1);
+ gcc_assert (double_int_fits_in_uhwi_p (i));
+ return i.low;
}
/* Other datastructures + helpers for output_constructor. */
else if (TREE_CODE (local.type) == ARRAY_TYPE)
local.index = ce->index;
-#ifdef ASM_COMMENT_START
if (local.field && flag_verbose_asm)
fprintf (asm_out_file, "%s %s:\n",
ASM_COMMENT_START,
DECL_NAME (local.field)
? IDENTIFIER_POINTER (DECL_NAME (local.field))
: "<anonymous>");
-#endif
/* Eliminate the marker that makes a cast not be an lvalue. */
if (local.val != NULL_TREE)
if (!(flags & SECTION_DEBUG))
*f++ = 'a';
+ if (flags & SECTION_EXCLUDE)
+ *f++ = 'e';
if (flags & SECTION_WRITE)
*f++ = 'w';
if (flags & SECTION_CODE)
type = "progbits";
format = ",@%s";
-#ifdef ASM_COMMENT_START
/* On platforms that use "@" as the assembly comment character,
use "%" instead. */
if (strcmp (ASM_COMMENT_START, "@") == 0)
format = ",%%%s";
-#endif
fprintf (asm_out_file, format, type);
if (flags & SECTION_ENTSIZE)
resolution_to_local_definition_p (enum ld_plugin_symbol_resolution resolution)
{
return (resolution == LDPR_PREVAILING_DEF
+ || resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
|| resolution == LDPR_PREVAILING_DEF_IRONLY);
}
{
return (resolution == LDPR_PREVAILING_DEF
|| resolution == LDPR_PREVAILING_DEF_IRONLY
+ || resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
|| resolution == LDPR_PREEMPTED_REG
|| resolution == LDPR_PREEMPTED_IR
|| resolution == LDPR_RESOLVED_IR
bool resolved_to_local_def = false;
/* With resolution file in hands, take look into resolutions.
- We can't just return true for resolved_localy symbols,
+ We can't just return true for resolved_locally symbols,
because dynamic linking might overwrite symbols
in shared libraries. */
if (TREE_CODE (exp) == VAR_DECL && TREE_PUBLIC (exp)
}
else if (TREE_CODE (exp) == FUNCTION_DECL && TREE_PUBLIC (exp))
{
- struct cgraph_node *node = cgraph_get_node_or_alias (exp);
+ struct cgraph_node *node = cgraph_get_node (exp);
if (node
&& resolution_local_p (node->resolution))
resolved_locally = true;
}
else if (TREE_CODE (decl) == FUNCTION_DECL)
{
- struct cgraph_node *node = cgraph_get_node_or_alias (decl);
+ struct cgraph_node *node = cgraph_get_node (decl);
if (node
&& node->resolution != LDPR_UNKNOWN)
return resolution_to_local_definition_p (node->resolution);
}
/* Otherwise we have to assume the worst for DECL_WEAK (hidden weaks
- binds localy but still can be overwritten).
+ binds locally but still can be overwritten).
This rely on fact that binds_local_p behave as decl_replaceable_p
for all other declaration types. */
return !DECL_WEAK (decl);
return dval;
}
+static GTY(()) section *elf_init_array_section;
+static GTY(()) section *elf_fini_array_section;
+
+static section *
+get_elf_initfini_array_priority_section (int priority,
+ bool constructor_p)
+{
+ section *sec;
+ if (priority != DEFAULT_INIT_PRIORITY)
+ {
+ char buf[18];
+ sprintf (buf, "%s.%.5u",
+ constructor_p ? ".init_array" : ".fini_array",
+ priority);
+ sec = get_section (buf, SECTION_WRITE, NULL_TREE);
+ }
+ else
+ {
+ if (constructor_p)
+ {
+ if (elf_init_array_section == NULL)
+ elf_init_array_section
+ = get_unnamed_section (0, output_section_asm_op,
+ "\t.section\t.init_array");
+ sec = elf_init_array_section;
+ }
+ else
+ {
+ if (elf_fini_array_section == NULL)
+ elf_fini_array_section
+ = get_unnamed_section (0, output_section_asm_op,
+ "\t.section\t.fini_array");
+ sec = elf_fini_array_section;
+ }
+ }
+ return sec;
+}
+
+/* Use .init_array section for constructors. */
+
+void
+default_elf_init_array_asm_out_constructor (rtx symbol, int priority)
+{
+ section *sec = get_elf_initfini_array_priority_section (priority,
+ true);
+ assemble_addr_to_section (symbol, sec);
+}
+
+/* Use .fini_array section for destructors. */
+
+void
+default_elf_fini_array_asm_out_destructor (rtx symbol, int priority)
+{
+ section *sec = get_elf_initfini_array_priority_section (priority,
+ false);
+ assemble_addr_to_section (symbol, sec);
+}
+
#include "gt-varasm.h"