Skip to content

Commit

Permalink
[AArch64, ILP32] 2/6 Parametrize elfnn-aarch64.c and add basic suppor…
Browse files Browse the repository at this point in the history
…t in ld

and gas.

bfd/

	* Makefile.am (BFD64_BACKENDS): Add elf32-aarch64.lo.
	(BUILD_CFILES): Add elf32-aarch64.c.
	(elf32-aarch64.c): New rule for generating from elfnn-aarch64.c.
	* Makefile.in: Re-generated.
	* archures.c (bfd_mach_aarch64_ilp32): New define.
	* bfd-in.h (bfd_elf32_aarch64_init_maps): New declaration.
	(bfd_elf32_aarch64_set_options): Ditto.
	(elf32_aarch64_setup_section_lists): Ditto.
	(elf32_aarch64_next_input_section): Ditto.
	(elf32_aarch64_size_stubs): Ditto.
	(elf32_aarch64_build_stubs): Ditto.
	* bfd-in2.h: Re-generated.
	* config.bfd (aarch64-*-elf): Add bfd_elf32_littleaarch64_vec
	and bfd_elf32_bigaarch64_vec.
	(aarch64-*-linux*): Likewise.
	(aarch64_be-*-elf): Likewise.
	(aarch64_be-*-linux*): Likewise.
	* configure.in (bfd_elf32_bigaarch64_vec)
	(bfd_elf32_littleaarch64_vec): New.
	* configure: Re-generated.
	* cpu-aarch64.c (compatible): Don't allow mixing ilp32 objects with
	lp64 ones.
	(bfd_aarch64_arch_ilp32): New.
	(bfd_aarch64_arch): Link to bfd_aarch64_arch_ilp32.
	* elfnn-aarch64.c (ARCH_SIZE): New define.
	(AARCH64_R, AARCH64_R_STR, LOG_FILE_ALIGN): New defines.
	(GOT_ENTRY_SIZE): Re-define as (ARCH_SIZE / 8).
	(elf64_aarch64_*): Rename to elfNN_aarch64_*.
	(ELF64_R_*): Rename to ELFNN_R_*.
	Plus other paramaterization.
	* targets.c (bfd_elf32_bigaarch64_vec, bfd_elf32_littleaarch64_vec):
	New declarations.
	(_bfd_target_vector): Add bfd_elf32_bigaarch64_vec and
	bfd_elf32_littleaarch64_vec.

gas/

	* config/tc-aarch64.c (ilp32_p): New static variable.
	(elf64_aarch64_target_format): Return the target according to the
	value of 'ilp32_p'.
	(md_begin): Determine 'mach' according to the value of 'ilp32_p'.
	(aarch64_opts): Add support for options '-milp32' and '-mlp64'.
	(aarch64_dwarf2_addr_size): New function.
	* config/tc-aarch64.h (aarch64_dwarf2_addr_size): New declaration.
	(DWARF2_ADDR_SIZE): New define.

ld/

	* Makefile.am (ALL_64_EMULATION_SOURCES): Add eaarch64elf32.c.
	(eaarch64elf32.c): New dependency and rule.
	* Makefile.in: Re-generated.
	* configure.tgt (aarch64-*-elf): Add aarch64elf32.
	(aarch64_be-*-elf, aarch64_be-*-linux*, aarch64-*-linux*): Likewise.
	* emulparams/aarch64elf32.sh: New file.
  • Loading branch information
Yufeng Zhang committed Jun 26, 2013
1 parent 8119711 commit cec5225
Show file tree
Hide file tree
Showing 19 changed files with 590 additions and 402 deletions.
37 changes: 37 additions & 0 deletions bfd/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
2013-06-26 Yufeng Zhang <yufeng.zhang@arm.com>

* Makefile.am (BFD64_BACKENDS): Add elf32-aarch64.lo.
(BUILD_CFILES): Add elf32-aarch64.c.
(elf32-aarch64.c): New rule for generating from elfnn-aarch64.c.
* Makefile.in: Re-generated.
* archures.c (bfd_mach_aarch64_ilp32): New define.
* bfd-in.h (bfd_elf32_aarch64_init_maps): New declaration.
(bfd_elf32_aarch64_set_options): Ditto.
(elf32_aarch64_setup_section_lists): Ditto.
(elf32_aarch64_next_input_section): Ditto.
(elf32_aarch64_size_stubs): Ditto.
(elf32_aarch64_build_stubs): Ditto.
* bfd-in2.h: Re-generated.
* config.bfd (aarch64-*-elf): Add bfd_elf32_littleaarch64_vec
and bfd_elf32_bigaarch64_vec.
(aarch64-*-linux*): Likewise.
(aarch64_be-*-elf): Likewise.
(aarch64_be-*-linux*): Likewise.
* configure.in (bfd_elf32_bigaarch64_vec)
(bfd_elf32_littleaarch64_vec): New.
* configure: Re-generated.
* cpu-aarch64.c (compatible): Don't allow mixing ilp32 objects with
lp64 ones.
(bfd_aarch64_arch_ilp32): New.
(bfd_aarch64_arch): Link to bfd_aarch64_arch_ilp32.
* elfnn-aarch64.c (ARCH_SIZE): New define.
(AARCH64_R, AARCH64_R_STR, LOG_FILE_ALIGN): New defines.
(GOT_ENTRY_SIZE): Re-define as (ARCH_SIZE / 8).
(elf64_aarch64_*): Rename to elfNN_aarch64_*.
(ELF64_R_*): Rename to ELFNN_R_*.
Plus other paramaterization.
* targets.c (bfd_elf32_bigaarch64_vec, bfd_elf32_littleaarch64_vec):
New declarations.
(_bfd_target_vector): Add bfd_elf32_bigaarch64_vec and
bfd_elf32_littleaarch64_vec.

2013-06-26 Yufeng Zhang <yufeng.zhang@arm.com>

* Makefile.am (BFD64_BACKENDS_CFILES): Remove elf64-aarch64.c.
Expand Down
8 changes: 7 additions & 1 deletion bfd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ BFD32_BACKENDS_CFILES = \
# elf32-ia64.c requires a 64-bit bfd_vma, and hence can not be put in
# BFD32_BACKENDS.
BFD64_BACKENDS = \
elf32-aarch64.lo \
elf64-aarch64.lo \
aix5ppc-core.lo \
aout64.lo \
Expand Down Expand Up @@ -763,7 +764,7 @@ SOURCE_CFILES = \
$(OPTIONAL_BACKENDS_CFILES)

BUILD_CFILES = \
elf64-aarch64.c \
elf32-aarch64.c elf64-aarch64.c \
elf32-ia64.c elf64-ia64.c peigen.c pepigen.c pex64igen.c

CFILES = $(SOURCE_CFILES) $(BUILD_CFILES)
Expand Down Expand Up @@ -912,6 +913,11 @@ elf64-target.h : elfxx-target.h
sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
mv -f elf64-target.new elf64-target.h

elf32-aarch64.c : elfnn-aarch64.c
rm -f elf32-aarch64.c
sed -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c > elf32-aarch64.new
mv -f elf32-aarch64.new elf32-aarch64.c

elf64-aarch64.c : elfnn-aarch64.c
rm -f elf64-aarch64.c
sed -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c > elf64-aarch64.new
Expand Down
9 changes: 8 additions & 1 deletion bfd/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ BFD32_BACKENDS_CFILES = \
# elf32-ia64.c requires a 64-bit bfd_vma, and hence can not be put in
# BFD32_BACKENDS.
BFD64_BACKENDS = \
elf32-aarch64.lo \
elf64-aarch64.lo \
aix5ppc-core.lo \
aout64.lo \
Expand Down Expand Up @@ -1068,7 +1069,7 @@ SOURCE_CFILES = \
$(OPTIONAL_BACKENDS_CFILES)

BUILD_CFILES = \
elf64-aarch64.c \
elf32-aarch64.c elf64-aarch64.c \
elf32-ia64.c elf64-ia64.c peigen.c pepigen.c pex64igen.c

CFILES = $(SOURCE_CFILES) $(BUILD_CFILES)
Expand Down Expand Up @@ -1397,6 +1398,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-strtab.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-vxworks.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-aarch64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-am33lin.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-arc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-arm.Plo@am__quote@
Expand Down Expand Up @@ -1989,6 +1991,11 @@ elf64-target.h : elfxx-target.h
sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
mv -f elf64-target.new elf64-target.h

elf32-aarch64.c : elfnn-aarch64.c
rm -f elf32-aarch64.c
sed -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c > elf32-aarch64.new
mv -f elf32-aarch64.new elf32-aarch64.c

elf64-aarch64.c : elfnn-aarch64.c
rm -f elf64-aarch64.c
sed -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c > elf64-aarch64.new
Expand Down
1 change: 1 addition & 0 deletions bfd/archures.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ DESCRIPTION
.#define bfd_mach_tilegx32 2
. bfd_arch_aarch64, {* AArch64 *}
.#define bfd_mach_aarch64 0
.#define bfd_mach_aarch64_ilp32 32
. bfd_arch_nios2,
.#define bfd_mach_nios2 0
. bfd_arch_last
Expand Down
20 changes: 19 additions & 1 deletion bfd/bfd-in.h
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,15 @@ extern unsigned int _bfd_elf_ppc_at_tprel_transform
extern void bfd_elf64_aarch64_init_maps
(bfd *);

extern void bfd_elf32_aarch64_init_maps
(bfd *);

extern void bfd_elf64_aarch64_set_options
(bfd *, struct bfd_link_info *, int, int, int);

extern void bfd_elf32_aarch64_set_options
(bfd *, struct bfd_link_info *, int, int, int);

/* ELF AArch64 mapping symbol support. */
#define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP (1 << 0)
#define BFD_AARCH64_SPECIAL_SYM_TYPE_TAG (1 << 1)
Expand All @@ -944,7 +950,7 @@ extern void bfd_elf64_aarch64_set_options
extern bfd_boolean bfd_is_aarch64_special_symbol_name
(const char * name, int type);

/* AArch64 stub generation support. Called from the linker. */
/* AArch64 stub generation support for ELF64. Called from the linker. */
extern int elf64_aarch64_setup_section_lists
(bfd *, struct bfd_link_info *);
extern void elf64_aarch64_next_input_section
Expand All @@ -955,6 +961,18 @@ extern bfd_boolean elf64_aarch64_size_stubs
void (*) (void));
extern bfd_boolean elf64_aarch64_build_stubs
(struct bfd_link_info *);
/* AArch64 stub generation support for ELF32. Called from the linker. */
extern int elf32_aarch64_setup_section_lists
(bfd *, struct bfd_link_info *);
extern void elf32_aarch64_next_input_section
(struct bfd_link_info *, struct bfd_section *);
extern bfd_boolean elf32_aarch64_size_stubs
(bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
struct bfd_section * (*) (const char *, struct bfd_section *),
void (*) (void));
extern bfd_boolean elf32_aarch64_build_stubs
(struct bfd_link_info *);


/* TI COFF load page support. */
extern void bfd_ticoff_set_section_load_page
Expand Down
21 changes: 20 additions & 1 deletion bfd/bfd-in2.h
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,15 @@ extern unsigned int _bfd_elf_ppc_at_tprel_transform
extern void bfd_elf64_aarch64_init_maps
(bfd *);

extern void bfd_elf32_aarch64_init_maps
(bfd *);

extern void bfd_elf64_aarch64_set_options
(bfd *, struct bfd_link_info *, int, int, int);

extern void bfd_elf32_aarch64_set_options
(bfd *, struct bfd_link_info *, int, int, int);

/* ELF AArch64 mapping symbol support. */
#define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP (1 << 0)
#define BFD_AARCH64_SPECIAL_SYM_TYPE_TAG (1 << 1)
Expand All @@ -951,7 +957,7 @@ extern void bfd_elf64_aarch64_set_options
extern bfd_boolean bfd_is_aarch64_special_symbol_name
(const char * name, int type);

/* AArch64 stub generation support. Called from the linker. */
/* AArch64 stub generation support for ELF64. Called from the linker. */
extern int elf64_aarch64_setup_section_lists
(bfd *, struct bfd_link_info *);
extern void elf64_aarch64_next_input_section
Expand All @@ -962,6 +968,18 @@ extern bfd_boolean elf64_aarch64_size_stubs
void (*) (void));
extern bfd_boolean elf64_aarch64_build_stubs
(struct bfd_link_info *);
/* AArch64 stub generation support for ELF32. Called from the linker. */
extern int elf32_aarch64_setup_section_lists
(bfd *, struct bfd_link_info *);
extern void elf32_aarch64_next_input_section
(struct bfd_link_info *, struct bfd_section *);
extern bfd_boolean elf32_aarch64_size_stubs
(bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
struct bfd_section * (*) (const char *, struct bfd_section *),
void (*) (void));
extern bfd_boolean elf32_aarch64_build_stubs
(struct bfd_link_info *);


/* TI COFF load page support. */
extern void bfd_ticoff_set_section_load_page
Expand Down Expand Up @@ -2214,6 +2232,7 @@ enum bfd_architecture
#define bfd_mach_tilegx32 2
bfd_arch_aarch64, /* AArch64 */
#define bfd_mach_aarch64 0
#define bfd_mach_aarch64_ilp32 32
bfd_arch_nios2,
#define bfd_mach_nios2 0
bfd_arch_last
Expand Down
8 changes: 4 additions & 4 deletions bfd/config.bfd
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,22 @@ case "${targ}" in
#ifdef BFD64
aarch64-*-elf)
targ_defvec=bfd_elf64_littleaarch64_vec
targ_selvecs="bfd_elf64_bigaarch64_vec bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec"
targ_selvecs="bfd_elf64_bigaarch64_vec bfd_elf32_littleaarch64_vec bfd_elf32_bigaarch64_vec bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec"
want64=true
;;
aarch64_be-*-elf)
targ_defvec=bfd_elf64_bigaarch64_vec
targ_selvecs="bfd_elf64_littleaarch64_vec bfd_elf32_bigarm_vec bfd_elf32_littlearm_vec"
targ_selvecs="bfd_elf64_littleaarch64_vec bfd_elf32_littleaarch64_vec bfd_elf32_bigaarch64_vec bfd_elf32_bigarm_vec bfd_elf32_littlearm_vec"
want64=true
;;
aarch64-*-linux*)
targ_defvec=bfd_elf64_littleaarch64_vec
targ_selvecs="bfd_elf64_bigaarch64_vec bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec"
targ_selvecs="bfd_elf64_bigaarch64_vec bfd_elf32_littleaarch64_vec bfd_elf32_bigaarch64_vec bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec"
want64=true
;;
aarch64_be-*-linux*)
targ_defvec=bfd_elf64_bigaarch64_vec
targ_selvecs="bfd_elf64_littleaarch64_vec bfd_elf32_bigarm_vec bfd_elf32_littlearm_vec"
targ_selvecs="bfd_elf64_littleaarch64_vec bfd_elf32_littleaarch64_vec bfd_elf32_bigaarch64_vec bfd_elf32_bigarm_vec bfd_elf32_littlearm_vec"
want64=true
;;
alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
Expand Down
2 changes: 2 additions & 0 deletions bfd/configure
Original file line number Diff line number Diff line change
Expand Up @@ -15365,6 +15365,7 @@ do
bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_bigaarch64_vec) tb="$tb elf64-aarch64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf32_bigaarch64_vec) tb="$tb elf32-aarch64.lo elf32.lo $elf"; target_size=64 ;;
bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
Expand All @@ -15374,6 +15375,7 @@ do
bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_ia64_vms_vec) tb="$tb elf64-ia64-vms.lo elf64-ia64.lo elfxx-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;;
bfd_elf64_littleaarch64_vec)tb="$tb elf64-aarch64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf32_littleaarch64_vec)tb="$tb elf32-aarch64.lo elf32.lo $elf"; target_size=64 ;;
bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
Expand Down
2 changes: 2 additions & 0 deletions bfd/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ do
bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_bigaarch64_vec) tb="$tb elf64-aarch64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf32_bigaarch64_vec) tb="$tb elf32-aarch64.lo elf32.lo $elf"; target_size=64 ;;
bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
Expand All @@ -869,6 +870,7 @@ do
bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_ia64_vms_vec) tb="$tb elf64-ia64-vms.lo elf64-ia64.lo elfxx-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;;
bfd_elf64_littleaarch64_vec)tb="$tb elf64-aarch64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf32_littleaarch64_vec)tb="$tb elf32-aarch64.lo elf32.lo $elf"; target_size=64 ;;
bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
Expand Down
10 changes: 8 additions & 2 deletions bfd/cpu-aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ compatible (const bfd_arch_info_type * a, const bfd_arch_info_type * b)
if (a->mach == b->mach)
return a;

/* Don't allow mixing ilp32 with lp64. */
if ((a->mach & bfd_mach_aarch64_ilp32) != (b->mach & bfd_mach_aarch64_ilp32))
return NULL;

/* Otherwise if either a or b is the 'default' machine
then it can be polymorphed into the other. */
if (a->the_default)
Expand Down Expand Up @@ -101,9 +105,11 @@ scan (const struct bfd_arch_info *info, const char *string)
"aarch64", PRINT, 4, DEFAULT, compatible, scan, \
bfd_arch_default_fill, NEXT }

const bfd_arch_info_type bfd_aarch64_arch =
N (0, "aarch64", TRUE, NULL);
static const bfd_arch_info_type bfd_aarch64_arch_ilp32 =
N (bfd_mach_aarch64_ilp32, "aarch64:ilp32", FALSE, NULL);

const bfd_arch_info_type bfd_aarch64_arch =
N (0, "aarch64", TRUE, &bfd_aarch64_arch_ilp32);

bfd_boolean
bfd_is_aarch64_special_symbol_name (const char *name, int type)
Expand Down
Loading

0 comments on commit cec5225

Please sign in to comment.