From b7d40e7d57fc189bb32beb0d78175b00c23cbc04 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 12 Aug 2002 09:53:12 +0000 Subject: Fix the gcc wrapper to include crtbeginS.o and crtendS.o when we are compiling PIC code, and use crtbegin.o and crtend.o when compiling non-pic code. As was caused problems, esp on powerpc... -Erik --- extra/gcc-uClibc/gcc-uClibc.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'extra/gcc-uClibc') diff --git a/extra/gcc-uClibc/gcc-uClibc.c b/extra/gcc-uClibc/gcc-uClibc.c index a5dcee31c..962ecae42 100644 --- a/extra/gcc-uClibc/gcc-uClibc.c +++ b/extra/gcc-uClibc/gcc-uClibc.c @@ -119,7 +119,7 @@ void xstrcat(char **string, ...) int main(int argc, char **argv) { int use_build_dir = 0, linking = 1, use_static_linking = 0; - int use_stdinc = 1, use_start = 1, use_stdlib = 1; + int use_stdinc = 1, use_start = 1, use_stdlib = 1, use_pic = 0; int source_count = 0, use_rpath = 0, verbose = 0; int ctor_dtor = 0, cplusplus = 0; int i, j, k, l, m, n; @@ -282,6 +282,15 @@ int main(int argc, char **argv) } } break; + case 'f': + /* Check if we are doing PIC */ + if (strcmp("-fPIC",argv[i]) == 0) { + use_pic = 1; + } else if (strcmp("-fpic",argv[i]) == 0) { + use_pic = 1; + } + break; + case '-': if (strstr(argv[i]+1,static_linking) != NULL) { use_static_linking = 1; @@ -372,7 +381,11 @@ int main(int argc, char **argv) if (use_start) { if (ctor_dtor) { gcc_argv[i++] = crti_path[use_build_dir]; - gcc_argv[i++] = GCC_LIB_DIR "crtbegin.o" ; + if (use_pic) { + gcc_argv[i++] = GCC_LIB_DIR "crtbeginS.o" ; + } else { + gcc_argv[i++] = GCC_LIB_DIR "crtbegin.o" ; + } } gcc_argv[i++] = crt0_path[use_build_dir]; } @@ -394,7 +407,11 @@ int main(int argc, char **argv) //gcc_argv[i++] = "-Wl,--end-group"; } if (ctor_dtor) { - gcc_argv[i++] = GCC_LIB_DIR "crtend.o" ; + if (use_pic) { + gcc_argv[i++] = GCC_LIB_DIR "crtendS.o" ; + } else { + gcc_argv[i++] = GCC_LIB_DIR "crtend.o" ; + } gcc_argv[i++] = crtn_path[use_build_dir]; } } else { -- cgit v1.2.3