This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][ARM]Use different startfile and endfile for elf target when generating shared object.
- From: Renlin Li <renlin dot li at foss dot arm dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Kyrill Tkachov <kyrylo dot tkachov at arm dot com>, Ramana Radhakrishnan <Ramana dot Radhakrishnan at arm dot com>
- Date: Thu, 16 Jun 2016 12:04:11 +0100
- Subject: [PATCH][ARM]Use different startfile and endfile for elf target when generating shared object.
- Authentication-results: sourceware.org; auth=none
Hi all,
GCC has startfile and endfile spec string built into it.
startfile is used to specify objects files to include at the start of
the link process. While endfile, on the other hand, is used to specify
objects files to include at the end of the link process.
crtbegin.o is one of the object files specified by startfile spec
string. IIUC, crtbeginS.o should be used in place of crtbegin.o when
generating shared objects.
The same applies to crtend.o which is one of the endfile. crtendS.o
should be used when generating shared objects.
This patch makes the change to use different crtbegin and crtend files
when creating shared and static object for elf toolchain. The linux
toolchain already did this differentiation.
So when the toolchain doesn't support shared object, the following error
message will be produced:
ld: cannot find crtbeginS.o: No such file or directory
Still, those specs strings built into GCC can be overridden by using
-specs=command-line switch to specify a spec file.
arm-none-eabi regression test without new issues, OK for trunk?
Regards,
Renlin Li
gcc/ChangeLog:
2016-06-16 Renlin Li <renlin.li@arm.com>
* config/arm/unknown-elf.h (UNKNOWN_ELF_STARTFILE_SPEC): Use
crtbeginS.o for shared object.
(UNKNOWN_ELF_ENDFILE_SPEC): Use crtendS.o for shared object.
diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h
index fafe057..12ef497 100644
--- a/gcc/config/arm/unknown-elf.h
+++ b/gcc/config/arm/unknown-elf.h
@@ -29,14 +29,19 @@
#endif
/* Now we define the strings used to build the spec file. */
-#define UNKNOWN_ELF_STARTFILE_SPEC " crti%O%s crtbegin%O%s crt0%O%s"
+#define UNKNOWN_ELF_STARTFILE_SPEC \
+ "crti%O%s \
+ %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s} \
+ crt0%O%s"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
"%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} " \
UNKNOWN_ELF_STARTFILE_SPEC
-#define UNKNOWN_ELF_ENDFILE_SPEC "crtend%O%s crtn%O%s"
+#define UNKNOWN_ELF_ENDFILE_SPEC \
+ "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \
+ crtn%O%s"
#undef ENDFILE_SPEC
#define ENDFILE_SPEC UNKNOWN_ELF_ENDFILE_SPEC