Skip to content

Commit 07d7df3

Browse files
eukarpovgithub-actions
authored andcommitted
aarch64: Multiple adjustments to support the SMALL code model correctly (#23)
LOCAL_LABEL_PREFIX has been changed to help the assembly compiler recognize local labels. The anchors have been disabled as they use symbol + offset, which is not applicable for COFF AArch64. Emitting locals has been replaced to use the .lcomm directive to declare uninitialized data without defining an exact section. aarch64.cc has been adjusted to prevent emitting symbol + offset for SYMBOL_SMALL_ABSOLUTE. Instead, it will emit an offset with the "add" instruction to correct the address. The added code is a duplicate of the code from SYMBOL_SMALL_GOT_4G handling and will be refactored during the patch series preparation for the mailing list. Functions and objects have been missing declarations. Binutils was not able to distinguish static from external, an object from a function. PE_COFF_LEGITIMIZE_EXTERN_DECL has been disabled, as it is needed for MEDIUM and LARGE models with -fPIC. These models are not yet implemented for AArch64. This fix relies on changes in binutils. aarch64: Fix IMAGE_REL_ARM64_PAGEBASE_REL21 relocation and symbol reduction for relocations This change resolves the following issues: Relocation overflow when a struct is large Relocation overflow issue when building FFmpeg with -O3
1 parent 12dcb60 commit 07d7df3

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

gcc/config/aarch64/aarch64-coff.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
#ifndef GCC_AARCH64_COFF_H
2121
#define GCC_AARCH64_COFF_H
2222

23-
#ifndef LOCAL_LABEL_PREFIX
24-
# define LOCAL_LABEL_PREFIX ""
25-
#endif
23+
#undef LOCAL_LABEL_PREFIX
24+
#define LOCAL_LABEL_PREFIX "."
2625

2726
/* Using long long breaks -ansi and -std=c90, so these will need to be
2827
made conditional for an LLP64 ABI. */
@@ -37,6 +36,9 @@
3736

3837
#define TARGET_SEH 1
3938

39+
#undef TARGET_MAX_ANCHOR_OFFSET
40+
#define TARGET_MAX_ANCHOR_OFFSET 0
41+
4042
#ifndef ASM_GENERATE_INTERNAL_LABEL
4143
# define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
4244
sprintf (STRING, "*%s%s%u", LOCAL_LABEL_PREFIX, PREFIX, (unsigned int)(NUM))
@@ -56,19 +58,10 @@
5658
}
5759
#endif
5860

59-
/* Output a local common block. /bin/as can't do this, so hack a
60-
`.space' into the bss segment. Note that this is *bad* practice,
61-
which is guaranteed NOT to work since it doesn't define STATIC
62-
COMMON space but merely STATIC BSS space. */
63-
#ifndef ASM_OUTPUT_ALIGNED_LOCAL
64-
# define ASM_OUTPUT_ALIGNED_LOCAL(STREAM, NAME, SIZE, ALIGN) \
65-
{ \
66-
switch_to_section (bss_section); \
67-
ASM_OUTPUT_ALIGN (STREAM, floor_log2 (ALIGN / BITS_PER_UNIT)); \
68-
ASM_OUTPUT_LABEL (STREAM, NAME); \
69-
fprintf (STREAM, "\t.space\t%d\n", (int)(SIZE)); \
70-
}
71-
#endif
61+
#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
62+
( fputs (".lcomm ", (FILE)), \
63+
assemble_name ((FILE), (NAME)), \
64+
fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
7265

7366
#define ASM_OUTPUT_SKIP(STREAM, NBYTES) \
7467
fprintf (STREAM, "\t.space\t%d // skip\n", (int) (NBYTES))

gcc/config/aarch64/aarch64.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6224,6 +6224,15 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
62246224
case SYMBOL_TLSLE24:
62256225
case SYMBOL_TLSLE32:
62266226
case SYMBOL_TLSLE48:
6227+
if (const_offset != 0)
6228+
{
6229+
gcc_assert(can_create_pseudo_p ());
6230+
base = aarch64_force_temporary (int_mode, dest, base);
6231+
aarch64_add_offset (int_mode, dest, base, const_offset,
6232+
NULL_RTX, NULL_RTX, 0, false);
6233+
return;
6234+
}
6235+
62276236
aarch64_load_symref_appropriately (dest, imm, sty);
62286237
return;
62296238

@@ -31523,8 +31532,9 @@ aarch64_libgcc_floating_mode_supported_p
3152331532
/* Limit the maximum anchor offset to 4k-1, since that's the limit for a
3152431533
byte offset; we can do much more for larger data types, but have no way
3152531534
to determine the size of the access. We assume accesses are aligned. */
31526-
#undef TARGET_MAX_ANCHOR_OFFSET
31535+
#ifndef TARGET_MAX_ANCHOR_OFFSET
3152731536
#define TARGET_MAX_ANCHOR_OFFSET 4095
31537+
#endif
3152831538

3152931539
#undef TARGET_VECTORIZE_PREFERRED_DIV_AS_SHIFTS_OVER_MULT
3153031540
#define TARGET_VECTORIZE_PREFERRED_DIV_AS_SHIFTS_OVER_MULT \

gcc/config/aarch64/cygming.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,22 @@ extern void i386_pe_record_external_function (tree, const char *);
283283

284284
#define SUPPORTS_ONE_ONLY 1
285285

286+
#undef ASM_DECLARE_OBJECT_NAME
287+
#define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
288+
do { \
289+
fprintf (STREAM, "\t.def\t"); \
290+
assemble_name (STREAM, NAME); \
291+
fprintf (STREAM, ";\t.scl\t%d;\t.type\t%d;\t.endef\n", \
292+
3, (int) 0 << 4); \
293+
ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
294+
} while (0)
295+
296+
#undef ASM_DECLARE_FUNCTION_NAME
297+
#define ASM_DECLARE_FUNCTION_NAME(STR, NAME, DECL) \
298+
mingw_pe_declare_function_type (STR, NAME, TREE_PUBLIC (DECL)); \
299+
aarch64_declare_function_name (STR, NAME, DECL)
300+
301+
286302
/* Define this to be nonzero if static stack checking is supported. */
287303
#define STACK_CHECK_STATIC_BUILTIN 1
288304

@@ -298,7 +314,7 @@ extern void i386_pe_record_external_function (tree, const char *);
298314
#undef GOT_ALIAS_SET
299315
#define GOT_ALIAS_SET mingw_GOT_alias_set ()
300316

301-
#define PE_COFF_LEGITIMIZE_EXTERN_DECL 1
317+
#define PE_COFF_LEGITIMIZE_EXTERN_DECL 0
302318

303319
#define HAVE_64BIT_POINTERS 1
304320

0 commit comments

Comments
 (0)