Commit 46a99b06 by Iain Sandoe

re PR target/26427 (with -fsection-anchors with zero sized structs)


	PR target/26427
	PR target/33120
	PR testsuite/35710

gcc:
	* config/i386/darwin.h (ASM_OUTPUT_COMMON): Remove
	(ASM_OUTPUT_LOCAL): Likewise.
	* config/darwin-protos.h (darwin_asm_declare_object_name): New.
	(darwin_output_aligned_bss): Likewise.
	(darwin_asm_output_aligned_decl_local): Likewise.
	(darwin_asm_output_aligned_decl_common): Likewise.
	(darwin_use_anchors_for_symbol_p): Likewise.
	* config/rs6000/darwin.h (ASM_OUTPUT_COMMON): Remove.
	(TARGET_ASM_OUTPUT_ANCHOR): Define.
	(TARGET_USE_ANCHORS_FOR_SYMBOL_P): Define.
	(DARWIN_SECTION_ANCHORS): Set to 1.
	* config/darwin.c (emit_aligned_common): New var.
	(darwin_init_sections): Check that the Darwin private zero-size section
	marker is in range.
	(darwin_text_section): Check for zero-sized objects.
	(darwin_mergeable_string_section): Likewise.
	(darwin_mergeable_constant_section): Likewise.
	(machopic_select_section): Adjust to check for zero-sized objects.
	Assert that OBJC meta data are non-zero sized.
	(darwin_asm_declare_object_name): New.
	(darwin_asm_declare_constant_name): Adjust for zero-sized
	object sections.
	(BYTES_ZFILL): Define.
	(darwin_emit_weak_or_comdat): New.
	(darwin_emit_local_bss): New.
	(darwin_emit_common): New.
	(darwin_output_aligned_bss): New.
	(darwin_asm_output_aligned_decl_common): New.
	(darwin_asm_output_aligned_decl_local): New.
	(darwin_file_end): Disable subsections_via_symbols when section
	anchoring is active.
	(darwin_asm_output_anchor): Re-enable.
	(darwin_use_anchors_for_symbol_p): New.
	(darwin_override_options): Check for versions that can emit
	aligned common.  Update usage of flags to current.
	* config/darwin-sections.def: Update comments and flags for
	non-anchor sections.  zobj_const_section, zobj_data_section,
	zobj_bss_section, zobj_const_data_section: New.
	* config/darwin.h (ASM_DECLARE_OBJECT_NAME): Redefine.
	(ASM_OUTPUT_ALIGN): Make whitespace output consistent.
	(L2_MAX_OFILE_ALIGNMENT): Define.
	(ASM_OUTPUT_ALIGNED_BSS): Define.
	(ASM_OUTPUT_ALIGNED_DECL_LOCAL): Define.
	(ASM_OUTPUT_ALIGNED_DECL_COMMON): Define.
	(SECTION_NO_ANCHOR): Define.
	(TARGET_ASM_OUTPUT_ANCHOR) Define with a default of NULL.
	(DARWIN_SECTION_ANCHORS): Define with a default of 0.

boehm-gc:
	* dyn_load.c (GC_register_dynamic_libraries/DARWIN):  Add new writable
	data section names.
	(GC_dyld_name_for_hdr): Adjust layout.
	(GC_dyld_image_add): Adjust layout, add new Darwin sections, adjust
	debug to name the sections.
	(GC_dyld_image_remove): Adjust layout, remove new Darwin sections,
	adjust debug to name the sections.
	(GC_register_dynamic_libraries): Adjust layout.
	(GC_init_dyld): Likewise.
	(GC_register_main_static_data): Likewise.

gcc/testsuite:
	* gcc.target/powerpc/darwin-abi-12.c: Adjust for new allocators.
	* gcc.dg/pr26427.c: Remove redundant warning for powerpc.
	* gcc.dg/darwin-comm.c: Adjust for new allocators.
	* gcc.dg/darwin-sections.c: New test.
	* g++.dg/ext/instantiate2.C: Adjust for new allocators.


Co-Authored-By: Mike Stump <mrs@gcc.gnu.org>

From-SVN: r167242
parent 71f3e391
2010-11-29 Iain Sandoe <iains@gcc.gnu.org>
Mike Stump <mrs@gcc.gnu.org>
PR target/26427
PR target/33120
PR testsuite/35710
* dyn_load.c (GC_register_dynamic_libraries/DARWIN): Add new writable
data section names.
(GC_dyld_name_for_hdr): Adjust layout.
(GC_dyld_image_add): Adjust layout, add new Darwin sections, adjust
debug to name the sections.
(GC_dyld_image_remove): Adjust layout, remove new Darwin sections,
adjust debug to name the sections.
(GC_register_dynamic_libraries): Adjust layout.
(GC_init_dyld): Likewise.
(GC_register_main_static_data): Likewise.
2010-10-29 Paolo Bonzini <bonzini@gnu.org>
* configure: Regenerate.
......
......@@ -1157,72 +1157,167 @@ void GC_register_dynamic_libraries()
/*#define DARWIN_DEBUG*/
/* Writeable sections generally available on Darwin. */
const static struct {
const char *seg;
const char *sect;
} GC_dyld_sections[] = {
{ SEG_DATA, SECT_DATA },
/* Used by FSF GCC, but not by OSX system tools, so far. */
{ SEG_DATA, "__static_data" },
{ SEG_DATA, SECT_BSS },
{ SEG_DATA, SECT_COMMON }
{ SEG_DATA, SECT_COMMON },
/* FSF GCC - zero-sized object sections for targets supporting section
anchors. */
{ SEG_DATA, "__zobj_data" },
{ SEG_DATA, "__zobj_bss" }
};
/* Additional writeable sections:
GCC on Darwin constucts aligned sections "on demand", where the alignment
size is embedded in the section name. Furthermore, there are distintions
between sections containing private vs. public symbols.
It also constructs sections specifically for zero-sized objects, when the
target supports section anchors. */
const char * GC_dyld_add_sect_fmts[] =
{
"__bss%u",
"__pu_bss%u",
"__zo_bss%u",
"__zo_pu_bss%u",
NULL
} ;
/* Currently, mach-o will allow up to a max of 2^15 alignment in an
object file. */
#define L2_MAX_OFILE_ALIGNMENT 15
#ifdef DARWIN_DEBUG
static const char *GC_dyld_name_for_hdr(const struct GC_MACH_HEADER *hdr) {
unsigned long i,c;
c = _dyld_image_count();
for(i=0;i<c;i++) if(_dyld_get_image_header(i) == hdr)
return _dyld_get_image_name(i);
return NULL;
static const char *
GC_dyld_name_for_hdr (const struct GC_MACH_HEADER *hdr)
{
unsigned long i,c;
c = _dyld_image_count();
for (i=0;i<c;i++)
if(_dyld_get_image_header(i) == hdr)
return _dyld_get_image_name(i);
return NULL;
}
#endif
/* This should never be called by a thread holding the lock */
static void GC_dyld_image_add(const struct GC_MACH_HEADER *hdr, intptr_t slide)
static void
GC_dyld_image_add (const struct GC_MACH_HEADER *hdr, intptr_t slide)
{
unsigned long start,end,i;
const struct GC_MACH_SECTION *sec;
if (GC_no_dls) return;
for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
char secnam[16];
unsigned long start,end,i,j;
const struct GC_MACH_SECTION *sec;
const char *fmt;
if (GC_no_dls)
return;
for (i=0; i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]); i++)
{
sec = GC_GETSECTBYNAME (hdr, GC_dyld_sections[i].seg,
GC_dyld_sections[i].sect);
if(sec == NULL || sec->size == 0) continue;
start = slide + sec->addr;
end = start + sec->size;
# ifdef DARWIN_DEBUG
GC_printf4("Adding section at %p-%p (%lu bytes) from image %s\n",
start,end,sec->size,GC_dyld_name_for_hdr(hdr));
# endif
GC_add_roots((char*)start,(char*)end);
if(sec == NULL || sec->size == 0)
continue;
start = slide + sec->addr;
end = start + sec->size;
# ifdef DARWIN_DEBUG
GC_printf5("Adding section __DATA,%s at %p-%p (%lu bytes) from image %s\n",
GC_dyld_sections[i].sect, start,end,sec->size,GC_dyld_name_for_hdr(hdr));
# endif
GC_add_roots((char*)start,(char*)end);
}
# ifdef DARWIN_DEBUG
GC_print_static_roots();
# endif
/* Sections constructed on demand. */
j=0;
while ((fmt = GC_dyld_add_sect_fmts[j]) != NULL)
{
/* Add our manufactured aligned BSS sections. */
for (i=0; i<=L2_MAX_OFILE_ALIGNMENT; i++)
{
snprintf (secnam, 16, fmt, (unsigned)i);
sec = GC_GETSECTBYNAME (hdr, SEG_DATA, secnam);
if (sec == NULL || sec->size == 0)
continue;
start = slide + sec->addr;
end = start + sec->size;
# ifdef DARWIN_DEBUG
GC_printf5("Adding section __DATA,%s at %p-%p (%lu bytes) from image %s\n",
secnam, start,end,sec->size,GC_dyld_name_for_hdr(hdr));
# endif
GC_add_roots((char*)start,(char*)end);
}
j++;
}
# ifdef DARWIN_DEBUG
GC_print_static_roots();
# endif
}
/* This should never be called by a thread holding the lock */
static void GC_dyld_image_remove(const struct GC_MACH_HEADER *hdr,
intptr_t slide) {
unsigned long start,end,i;
const struct GC_MACH_SECTION *sec;
for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
static void
GC_dyld_image_remove (const struct GC_MACH_HEADER *hdr, intptr_t slide)
{
char secnam[16];
unsigned long start,end,i,j;
const struct GC_MACH_SECTION *sec;
const char *fmt;
for (i=0; i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]); i++)
{
sec = GC_GETSECTBYNAME (hdr, GC_dyld_sections[i].seg,
GC_dyld_sections[i].sect);
if(sec == NULL || sec->size == 0) continue;
start = slide + sec->addr;
end = start + sec->size;
# ifdef DARWIN_DEBUG
GC_printf4("Removing section at %p-%p (%lu bytes) from image %s\n",
start,end,sec->size,GC_dyld_name_for_hdr(hdr));
# endif
GC_remove_roots((char*)start,(char*)end);
if(sec == NULL || sec->size == 0)
continue;
start = slide + sec->addr;
end = start + sec->size;
# ifdef DARWIN_DEBUG
GC_printf5("Removing section __DATA,%s at %p-%p (%lu bytes) from image %s\n",
GC_dyld_sections[i].sect, start,end,sec->size,GC_dyld_name_for_hdr(hdr));
# endif
GC_remove_roots((char*)start,(char*)end);
}
# ifdef DARWIN_DEBUG
GC_print_static_roots();
# endif
/* Remove our on-demand sections. */
j=0;
while ((fmt = GC_dyld_add_sect_fmts[j]) != NULL)
{
for (i=0; i<=L2_MAX_OFILE_ALIGNMENT; i++)
{
snprintf (secnam, 16, fmt, (unsigned)i);
sec = GC_GETSECTBYNAME (hdr, SEG_DATA, secnam);
if (sec == NULL || sec->size == 0)
continue;
start = slide + sec->addr;
end = start + sec->size;
# ifdef DARWIN_DEBUG
GC_printf5("Removing section __DATA,%s at %p-%p (%lu bytes) from image %s\n",
secnam, start,end,sec->size,GC_dyld_name_for_hdr(hdr));
# endif
GC_remove_roots((char*)start,(char*)end);
}
j++;
}
# ifdef DARWIN_DEBUG
GC_print_static_roots();
# endif
}
void GC_register_dynamic_libraries() {
void
GC_register_dynamic_libraries()
{
/* Currently does nothing. The callbacks are setup by GC_init_dyld()
The dyld library takes it from there. */
}
......@@ -1233,15 +1328,18 @@ void GC_register_dynamic_libraries() {
This should be called BEFORE any thread in created and WITHOUT the
allocation lock held. */
void GC_init_dyld() {
void
GC_init_dyld()
{
static GC_bool initialized = FALSE;
char *bind_fully_env = NULL;
if(initialized) return;
if(initialized)
return;
# ifdef DARWIN_DEBUG
# ifdef DARWIN_DEBUG
GC_printf0("Registering dyld callbacks...\n");
# endif
# endif
/* Apple's Documentation:
When you call _dyld_register_func_for_add_image, the dynamic linker runtime
......@@ -1254,27 +1352,28 @@ void GC_init_dyld() {
linked in the future
*/
_dyld_register_func_for_add_image(GC_dyld_image_add);
_dyld_register_func_for_remove_image(GC_dyld_image_remove);
_dyld_register_func_for_add_image(GC_dyld_image_add);
_dyld_register_func_for_remove_image(GC_dyld_image_remove);
/* Set this early to avoid reentrancy issues. */
initialized = TRUE;
/* Set this early to avoid reentrancy issues. */
initialized = TRUE;
bind_fully_env = getenv("DYLD_BIND_AT_LAUNCH");
bind_fully_env = getenv("DYLD_BIND_AT_LAUNCH");
if (bind_fully_env == NULL) {
# ifdef DARWIN_DEBUG
if (bind_fully_env == NULL)
{
# ifdef DARWIN_DEBUG
GC_printf0("Forcing full bind of GC code...\n");
# endif
# endif
if(!_dyld_bind_fully_image_containing_address((unsigned long*)GC_malloc))
GC_abort("_dyld_bind_fully_image_containing_address failed");
if (!_dyld_bind_fully_image_containing_address((unsigned long*)GC_malloc))
GC_abort("_dyld_bind_fully_image_containing_address failed");
}
}
#define HAVE_REGISTER_MAIN_STATIC_DATA
GC_bool GC_register_main_static_data()
GC_bool
GC_register_main_static_data (void)
{
/* Already done through dyld callbacks */
return FALSE;
......
2010-11-29 Iain Sandoe <iains@gcc.gnu.org>
Mike Stump <mrs@gcc.gnu.org>
PR target/26427
PR target/33120
PR testsuite/35710
* config/i386/darwin.h (ASM_OUTPUT_COMMON): Remove
(ASM_OUTPUT_LOCAL): Likewise.
* config/darwin-protos.h (darwin_asm_declare_object_name): New.
(darwin_output_aligned_bss): Likewise.
(darwin_asm_output_aligned_decl_local): Likewise.
(darwin_asm_output_aligned_decl_common): Likewise.
(darwin_use_anchors_for_symbol_p): Likewise.
* config/rs6000/darwin.h (ASM_OUTPUT_COMMON): Remove.
(TARGET_ASM_OUTPUT_ANCHOR): Define.
(TARGET_USE_ANCHORS_FOR_SYMBOL_P): Define.
(DARWIN_SECTION_ANCHORS): Set to 1.
* config/darwin.c (emit_aligned_common): New var.
(darwin_init_sections): Check that the Darwin private zero-size section
marker is in range.
(darwin_text_section): Check for zero-sized objects.
(darwin_mergeable_string_section): Likewise.
(darwin_mergeable_constant_section): Likewise.
(machopic_select_section): Adjust to check for zero-sized objects.
Assert that OBJC meta data are non-zero sized.
(darwin_asm_declare_object_name): New.
(darwin_asm_declare_constant_name): Adjust for zero-sized
object sections.
(BYTES_ZFILL): Define.
(darwin_emit_weak_or_comdat): New.
(darwin_emit_local_bss): New.
(darwin_emit_common): New.
(darwin_output_aligned_bss): New.
(darwin_asm_output_aligned_decl_common): New.
(darwin_asm_output_aligned_decl_local): New.
(darwin_file_end): Disable subsections_via_symbols when section
anchoring is active.
(darwin_asm_output_anchor): Re-enable.
(darwin_use_anchors_for_symbol_p): New.
(darwin_override_options): Check for versions that can emit
aligned common. Update usage of flags to current.
* config/darwin-sections.def: Update comments and flags for
non-anchor sections. zobj_const_section, zobj_data_section,
zobj_bss_section, zobj_const_data_section: New.
* config/darwin.h (ASM_DECLARE_OBJECT_NAME): Redefine.
(ASM_OUTPUT_ALIGN): Make whitespace output consistent.
(L2_MAX_OFILE_ALIGNMENT): Define.
(ASM_OUTPUT_ALIGNED_BSS): Define.
(ASM_OUTPUT_ALIGNED_DECL_LOCAL): Define.
(ASM_OUTPUT_ALIGNED_DECL_COMMON): Define.
(SECTION_NO_ANCHOR): Define.
(TARGET_ASM_OUTPUT_ANCHOR) Define with a default of NULL.
(DARWIN_SECTION_ANCHORS): Define with a default of 0.
2010-11-29 Joseph Myers <joseph@codesourcery.com>
* system.h: Include "safe-ctype.h" instead of <safe-ctype.h>.
......@@ -85,12 +85,26 @@ extern tree darwin_handle_weak_import_attribute (tree *node, tree name,
extern void machopic_output_stub (FILE *, const char *, const char *);
extern void darwin_globalize_label (FILE *, const char *);
extern void darwin_assemble_visibility (tree, int);
extern void darwin_asm_output_dwarf_delta (FILE *, int, const char *,
const char *);
extern void darwin_asm_output_dwarf_offset (FILE *, int, const char *,
section *);
extern void darwin_asm_declare_object_name (FILE *, const char *, tree);
extern void darwin_asm_declare_constant_name (FILE *, const char *,
const_tree, HOST_WIDE_INT);
extern void darwin_output_aligned_bss (FILE *, tree, const char *,
unsigned HOST_WIDE_INT, unsigned int);
extern void darwin_asm_output_aligned_decl_local (FILE *, tree, const char *,
unsigned HOST_WIDE_INT,
unsigned int);
extern void darwin_asm_output_aligned_decl_common (FILE *, tree, const char *,
unsigned HOST_WIDE_INT,
unsigned int);
extern bool darwin_binds_local_p (const_tree);
extern void darwin_cpp_builtins (struct cpp_reader *);
......@@ -104,6 +118,7 @@ extern tree darwin_build_constant_cfstring (tree);
extern void darwin_enter_string_into_cfstring_table (tree);
extern void darwin_asm_output_anchor (rtx symbol);
extern bool darwin_use_anchors_for_symbol_p (const_rtx symbol);
extern bool darwin_kextabi_p (void);
extern void darwin_override_options (void);
extern void darwin_patch_builtins (void);
......@@ -16,30 +16,70 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
DEF_SECTION (text_coal_section, SECTION_CODE,
/* Since Darwin's ld will not allow zero-sized objects, and gcc wants them,
we emit one byte (in darwin.c) when such an object is encountered.
This messes up section anchoring because the emitted byte is not counted
outside the port. To cope with this, we set aside sections for zero-sized
objects and disallow those sections from participating in section anchors
("zobj_" sections, below).
Items that might be coalesced by the linker are prevented from participating,
(and those in mergeable sections are disallowed in varasm.c). */
/* .text handled in varasm.c */
DEF_SECTION (text_coal_section, SECTION_CODE|SECTION_NO_ANCHOR,
".section __TEXT,__textcoal_nt,coalesced,pure_instructions", 0)
DEF_SECTION (text_unlikely_coal_section, SECTION_CODE,
DEF_SECTION (text_unlikely_coal_section, SECTION_CODE|SECTION_NO_ANCHOR,
".section __TEXT,__text_unlikely_coal,"
"coalesced,pure_instructions", 0)
/* const */
DEF_SECTION (const_section, 0, ".const", 0)
DEF_SECTION (const_coal_section, 0,
DEF_SECTION (const_coal_section, SECTION_NO_ANCHOR,
".section __TEXT,__const_coal,coalesced", 0)
/* Place to put zero-sized to avoid issues with section anchors. */
DEF_SECTION (zobj_const_section, SECTION_NO_ANCHOR,
".section\t__DATA,__zobj_const", 0)
/* Write-able data. '.data' handled in varasm.c */
DEF_SECTION (static_data_section, SECTION_WRITE, ".static_data", 0)
DEF_SECTION (data_coal_section, SECTION_WRITE|SECTION_NO_ANCHOR,
".section __DATA,__datacoal_nt,coalesced", 0)
/* Place to put zero-sized to avoid issues with section anchors. */
DEF_SECTION (zobj_data_section, SECTION_WRITE|SECTION_NO_ANCHOR,
".section\t__DATA,__zobj_data", 0)
/* BSS - .lcomm / .zerofill __DATA,__bss sections cannot be switched to
explicitly (will create an assembler error). */
DEF_SECTION (zobj_bss_section, SECTION_WRITE|SECTION_BSS|SECTION_NO_ANCHOR,
".section\t__DATA,__zobj_bss", 0)
/* const data */
DEF_SECTION (const_data_section, 0, ".const_data", 0)
DEF_SECTION (const_data_coal_section, 0,
DEF_SECTION (const_data_coal_section, SECTION_NO_ANCHOR,
".section __DATA,__const_coal,coalesced", 0)
DEF_SECTION (data_coal_section, SECTION_WRITE,
".section __DATA,__datacoal_nt,coalesced", 0)
/* Place to put zero-sized to avoid issues with section anchors. */
DEF_SECTION (zobj_const_data_section, SECTION_NO_ANCHOR,
".section\t__DATA,__zobj_const_data", 0)
/* Strings and other literals. */
DEF_SECTION (cstring_section, SECTION_MERGE | SECTION_STRINGS, ".cstring", 0)
DEF_SECTION (literal4_section, SECTION_MERGE, ".literal4", 0)
DEF_SECTION (literal8_section, SECTION_MERGE, ".literal8", 0)
DEF_SECTION (literal16_section, SECTION_MERGE, ".literal16", 0)
/* Unlike constant NSStrings, constant CFStrings do not live in the __OBJC segment
since they may also occur in pure C or C++ programs. */
DEF_SECTION (cfstring_constant_object_section, 0, ".section __DATA, __cfstring", 0)
DEF_SECTION (constructor_section, 0, ".constructor", 0)
/* Unlike constant NSStrings, constant CFStrings do not live in the
__OBJC segment since they may also occur in pure C or C++ programs. */
DEF_SECTION (cfstring_constant_object_section, 0,
".section __DATA, __cfstring", 0)
/* Module init, term, constructors & destructors. */
DEF_SECTION (mod_init_section, 0, ".mod_init_func", 0)
DEF_SECTION (mod_term_section, 0, ".mod_term_func", 0)
DEF_SECTION (constructor_section, 0, ".constructor", 0)
DEF_SECTION (destructor_section, 0, ".destructor", 0)
/* Objective-C (V1) sections. */
DEF_SECTION (objc_class_section, 0, ".objc_class", 1)
DEF_SECTION (objc_meta_class_section, 0, ".objc_meta_class", 1)
DEF_SECTION (objc_category_section, 0, ".objc_category", 1)
......@@ -66,32 +106,38 @@ DEF_SECTION (objc_class_names_section, 0, ".objc_class_names", 1)
DEF_SECTION (objc_meth_var_names_section, 0, ".objc_meth_var_names", 1)
DEF_SECTION (objc_meth_var_types_section, 0, ".objc_meth_var_types", 1)
DEF_SECTION (objc_cls_refs_section, SECTION_MERGE, ".objc_cls_refs", 1)
/* Stubs and symbol indirection sections. */
/* lazy symbol pointers. */
DEF_SECTION (machopic_lazy_symbol_ptr_section, 0, ".lazy_symbol_pointer", 0)
DEF_SECTION (machopic_lazy_symbol_ptr2_section, 0,
DEF_SECTION (machopic_lazy_symbol_ptr_section, SECTION_NO_ANCHOR,
".lazy_symbol_pointer", 0)
DEF_SECTION (machopic_lazy_symbol_ptr2_section, SECTION_NO_ANCHOR,
".section __DATA, __la_sym_ptr2,lazy_symbol_pointers", 0)
DEF_SECTION (machopic_lazy_symbol_ptr3_section, 0,
DEF_SECTION (machopic_lazy_symbol_ptr3_section, SECTION_NO_ANCHOR,
".section __DATA, __la_sym_ptr3,lazy_symbol_pointers", 0)
/* non-lazy symbol pointers. */
DEF_SECTION (machopic_nl_symbol_ptr_section, 0,
DEF_SECTION (machopic_nl_symbol_ptr_section, SECTION_NO_ANCHOR,
MACHOPIC_NL_SYMBOL_PTR_SECTION, 0)
/* Symbol stubs. */
DEF_SECTION (machopic_symbol_stub_section, 0, ".symbol_stub", 0)
DEF_SECTION (machopic_symbol_stub1_section, 0,
DEF_SECTION (machopic_symbol_stub_section, SECTION_NO_ANCHOR,
".symbol_stub", 0)
DEF_SECTION (machopic_symbol_stub1_section, SECTION_NO_ANCHOR,
".section __TEXT,__symbol_stub1,symbol_stubs,"
"pure_instructions,16", 0)
/* PIC symbol stubs. */
DEF_SECTION (machopic_picsymbol_stub_section, 0, ".picsymbol_stub", 0)
DEF_SECTION (machopic_picsymbol_stub1_section, 0,
DEF_SECTION (machopic_picsymbol_stub_section, SECTION_NO_ANCHOR,
".picsymbol_stub", 0)
DEF_SECTION (machopic_picsymbol_stub1_section, SECTION_NO_ANCHOR,
".section __TEXT,__picsymbolstub1,symbol_stubs,"
"pure_instructions,32", 0)
DEF_SECTION (machopic_picsymbol_stub2_section, 0,
DEF_SECTION (machopic_picsymbol_stub2_section, SECTION_NO_ANCHOR,
".section __TEXT,__picsymbolstub2,symbol_stubs,pure_instructions,25", 0)
DEF_SECTION (machopic_picsymbol_stub3_section, 0,
DEF_SECTION (machopic_picsymbol_stub3_section, SECTION_NO_ANCHOR,
".section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5", 0)
/* Exception-related. */
DEF_SECTION (darwin_exception_section, 0,
DEF_SECTION (darwin_exception_section, SECTION_NO_ANCHOR,
".section __DATA,__gcc_except_tab", 0)
DEF_SECTION (darwin_eh_frame_section, 0,
DEF_SECTION (darwin_eh_frame_section, SECTION_NO_ANCHOR,
".section " EH_FRAME_SECTION_NAME ",__eh_frame"
EH_FRAME_SECTION_ATTR, 0)
......@@ -529,34 +529,16 @@ extern GTY(()) int darwin_ms_struct;
(CLASS_NAME), (SEL_NAME)); \
} while (0)
#undef ASM_DECLARE_OBJECT_NAME
#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
darwin_asm_declare_object_name ((FILE), (NAME), (DECL))
/* The RTTI data (e.g., __ti4name) is common and public (and static),
but it does need to be referenced via indirect PIC data pointers.
The machopic_define_symbol calls are telling the machopic subsystem
that the name *is* defined in this module, so it doesn't need to
make them indirect. */
#undef ASM_DECLARE_OBJECT_NAME
#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
do { \
const char *xname = NAME; \
if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
if (! DECL_WEAK (DECL) \
&& ((TREE_STATIC (DECL) \
&& (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
|| DECL_INITIAL (DECL))) \
machopic_define_symbol (DECL_RTL (DECL)); \
if ((TREE_STATIC (DECL) \
&& (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
|| DECL_INITIAL (DECL)) \
(* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
ASM_OUTPUT_LABEL (FILE, xname); \
/* Darwin doesn't support zero-size objects, so give them a \
byte. */ \
if (tree_low_cst (DECL_SIZE_UNIT (DECL), 1) == 0) \
assemble_zeros (1); \
} while (0)
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
do { \
const char *xname = NAME; \
......@@ -581,7 +563,6 @@ extern GTY(()) int darwin_ms_struct;
Make Objective-C internal symbols local and in doing this, we need
to accommodate the name mangling done by c++ on file scope locals. */
int darwin_label_is_anonymous_local_objc_name (const char *name);
#undef ASM_OUTPUT_LABELREF
......@@ -633,27 +614,7 @@ int darwin_label_is_anonymous_local_objc_name (const char *name);
#undef ASM_OUTPUT_ALIGN
#define ASM_OUTPUT_ALIGN(FILE,LOG) \
if ((LOG) != 0) \
fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
/* Ensure correct alignment of bss data. */
#undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
#define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
do { \
unsigned HOST_WIDE_INT _new_size = SIZE; \
fputs ("\t.lcomm ", (FILE)); \
assemble_name ((FILE), (NAME)); \
if (_new_size == 0) _new_size = 1; \
fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", _new_size, \
floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
if ((DECL) && ((TREE_STATIC (DECL) \
&& (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
|| DECL_INITIAL (DECL))) \
{ \
(* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
machopic_define_symbol (DECL_RTL (DECL)); \
} \
} while (0)
fprintf (FILE, "\t%s\t%d\n", ALIGN_ASM_OP, (LOG))
/* The maximum alignment which the object file format can support in
bits. For Mach-O, this is 2^15 bytes. */
......@@ -661,9 +622,30 @@ int darwin_label_is_anonymous_local_objc_name (const char *name);
#undef MAX_OFILE_ALIGNMENT
#define MAX_OFILE_ALIGNMENT (0x8000 * 8)
#define L2_MAX_OFILE_ALIGNMENT 15
/* These are the three variants that emit referenced blank space. */
#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
darwin_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
#undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
#define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
darwin_asm_output_aligned_decl_local \
((FILE), (DECL), (NAME), (SIZE), (ALIGN))
#undef ASM_OUTPUT_ALIGNED_DECL_COMMON
#define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
darwin_asm_output_aligned_decl_common \
((FILE), (DECL), (NAME), (SIZE), (ALIGN))
/* The generic version, archs should over-ride where required. */
#define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer"
/* Private flag applied to disable section-anchors in a particular section.
This needs to be kept in sync with the flags used by varasm.c (defined in
output.h). */
#define SECTION_NO_ANCHOR 0x2000000
/* Declare the section variables. */
#ifndef USED_FOR_TARGET
enum darwin_section_enum {
......@@ -911,17 +893,10 @@ void add_framework_path (char *);
#undef GOMP_SELF_SPECS
#define GOMP_SELF_SPECS ""
/* Darwin can't support anchors until we can cope with the adjustments
to size that ASM_DECLARE_OBJECT_NAME and ASM_DECLARE_CONSTANT_NAME
when outputting members of an anchor block and the linker can be
taught to keep them together or we find some other suitable
code-gen technique. */
#if 0
#define TARGET_ASM_OUTPUT_ANCHOR darwin_asm_output_anchor
#else
/* Darwin disables section anchors by default.
They should be enabled per arch where support exists in that arch. */
#define TARGET_ASM_OUTPUT_ANCHOR NULL
#endif
#define DARWIN_SECTION_ANCHORS 0
/* Attempt to turn on execute permission for the stack. This may be
used by TARGET_TRAMPOLINE_INIT if the target needs it (that is,
......
......@@ -213,22 +213,6 @@ extern int darwin_emit_branch_islands;
} \
} while (0)
/* This says how to output an assembler line
to define a global common symbol. */
#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
( fputs ("\t.comm ", (FILE)), \
assemble_name ((FILE), (NAME)), \
fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED)))
/* This says how to output an assembler line
to define a local common symbol. */
#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
( fputs ("\t.lcomm ", (FILE)), \
assemble_name ((FILE), (NAME)), \
fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED)))
/* Darwin profiling -- call mcount. */
#undef FUNCTION_PROFILER
#define FUNCTION_PROFILER(FILE, LABELNO) \
......
......@@ -232,17 +232,6 @@ extern int darwin_emit_branch_islands;
#define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \
fprintf (FILE, "%s", PREFIX)
/* This says how to output an assembler line to define a global common
symbol. */
#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
do { \
unsigned HOST_WIDE_INT _new_size = SIZE; \
fputs ("\t.comm ", (FILE)); \
RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
if (_new_size == 0) _new_size = 1; \
fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", _new_size); \
} while (0)
/* Override the standard rs6000 definition. */
#undef ASM_COMMENT_START
......@@ -423,6 +412,22 @@ extern int darwin_emit_branch_islands;
default, as kernel code doesn't save/restore those registers. */
#define OS_MISSING_ALTIVEC (flag_mkernel || flag_apple_kext)
/* Darwin has support for section anchors on powerpc*.
It is disabled for any section containing a "zero-sized item" (because these
are re-written as size=1 to be compatible with the OSX ld64).
The re-writing would interfere with the computation of anchor offsets.
Therefore, we place zero-sized items in their own sections and make such
sections unavailable to section anchoring. */
#undef TARGET_ASM_OUTPUT_ANCHOR
#define TARGET_ASM_OUTPUT_ANCHOR darwin_asm_output_anchor
#undef TARGET_USE_ANCHORS_FOR_SYMBOL_P
#define TARGET_USE_ANCHORS_FOR_SYMBOL_P darwin_use_anchors_for_symbol_p
#undef DARWIN_SECTION_ANCHORS
#define DARWIN_SECTION_ANCHORS 1
/* PPC Darwin has to rename some of the long double builtins. */
#undef SUBTARGET_INIT_BUILTINS
#define SUBTARGET_INIT_BUILTINS \
......
2010-11-29 Iain Sandoe <iains@gcc.gnu.org>
Mike Stump <mrs@gcc.gnu.org>
PR target/26427
PR target/33120
PR testsuite/35710
* gcc.target/powerpc/darwin-abi-12.c: Adjust for new allocators.
* gcc.dg/pr26427.c: Remove redundant warning for powerpc.
* gcc.dg/darwin-comm.c: Adjust for new allocators.
* gcc.dg/darwin-sections.c: New test.
* g++.dg/ext/instantiate2.C: Adjust for new allocators.
2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/exceptions-1.m: New.
......
......@@ -8,7 +8,8 @@ template <class T> struct A {
template <class T> T A<T>::t = 0;
static template struct A<int>;
// { dg-final { scan-assembler "\n_?_ZN1AIiE1tE(:|\n|\t)" } }
// { dg-final { scan-assembler "\n_?_ZN1AIiE1tE(:|\n|\t)" { target { ! *-*-darwin* } } } }
// { dg-final { scan-assembler ".zerofill __DATA,__pu_bss2,__ZN1AIiE1tE" { target *-*-darwin* } } }
void test_int() { A<int>::t = 42; }
// { dg-final { scan-assembler-not "\n_?_ZN1AIcE1tE(:|\n|\t)" } }
......
/* { dg-do compile { target *-*-darwin[912]* } } */
/* { dg-final { scan-assembler ".comm _foo,1,15" } } */
/* { dg-final { scan-assembler ".comm\[ \t\]_foo,1,15" } } */
char foo __attribute__ ((aligned(32768)));
/* { dg-do compile {target *-*-darwin* } } */
/* { dg-options "-std=c99 -w" } */
/* This has been designed to give the same section usage for
-m32 and -m64 - so don't put any ints or longs in it ... */
/* A zero-sized object. */
typedef struct _empty {} e_s;
/* These should go in .comm */
char ub;
e_s ea;
/* { dg-final { scan-assembler ".comm\[\t \]_ub,1" } } */
/* { dg-final { scan-assembler ".comm\[\t \]_ea,1" } } */
/* These should go into .data */
char a = 0;
short b = 0;
/* { dg-final { scan-assembler ".globl _a.*.data.*.space\[\t \]1" } } */
/* { dg-final { scan-assembler ".globl _b.*.data.*.space\[\t \]2" } } */
/* These should go into __pu_bssN */
long long d = 0;
float e = 0;
double f = 0;
long double g = 0.L;
long long al_256 __attribute__((aligned (256))) = 0;
/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss3,_d,8,3" } } */
/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss2,_e,4,2" } } */
/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss3,_f,8,3" } } */
/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss4,_g,16,4" } } */
/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss8,_al_256,8,8" } } */
/* This should go into __zo_bss0 */
static e_s sea;
/* { dg-final { scan-assembler ".zerofill __DATA,__zo_bss0,_sea,1" } } */
/* These should go into .static_data */
static char sa ;
static short sb ;
/* { dg-final { scan-assembler ".static_data.*_sa:.*.space\[\t \]1" } } */
/* { dg-final { scan-assembler ".static_data.*_sb:.*.space\[\t \]2" } } */
/* These should go into _bssN */
static long long sd;
static float se ;
static double sf ;
static long double sg;
static long long sal_256 __attribute__((aligned (2048)));
/* { dg-final { scan-assembler ".zerofill __DATA,__bss3,_sd,8,3" } } */
/* { dg-final { scan-assembler ".zerofill __DATA,__bss2,_se,4,2" } } */
/* { dg-final { scan-assembler ".zerofill __DATA,__bss3,_sf,8,3" } } */
/* { dg-final { scan-assembler ".zerofill __DATA,__bss4,_sg,16,4" } } */
/* { dg-final { scan-assembler ".zerofill __DATA,__bss11,_sal_256,8,11" } } */
long long foo (int x)
{
e_s *s;
a += x + sa;
b += a + sb;
d += b + sd;
e += d + se;
f += e + sf;
g += f + sg;
s = &ea;
s = &sea;
b += al_256;
b += sal_256;
return (long long) sd + b;
}
/* { dg-warning "this target does not support" } */
/* { dg-warning "this target does not support" "" {target *86*-*-darwin* } 0 } */
/* { dg-do run { target { *-*-darwin* } } } */
/* { dg-options { -fsection-anchors -O } } */
/* PR target/26427 */
......
/* { dg-do compile { target powerpc*-*-darwin* } } */
/* { dg-final { scan-assembler ".comm _x,12,2" } } */
/* { dg-final { scan-assembler ".comm\[\t \]_x,12,2" } } */
/* { dg-final { scan-assembler-not ".space 7" } } */
/* PR 23071 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment