]> code.ossystems Code Review - openembedded-core.git/commitdiff
gcc: fix check for target libc ssp support
authorKevin Tian <kevin.tian@intel.com>
Wed, 29 Sep 2010 00:54:33 +0000 (08:54 +0800)
committerSaul Wold <Saul.Wold@intel.com>
Thu, 30 Sep 2010 17:18:00 +0000 (10:18 -0700)
gcc uses hardcoded path "${with-build-sysroot}/usr/include" to check target
libc ssp support. Based on GLIBC version strings in features.h in that search
path, gcc knows whether target (e)glibc implements stack protector itself.

However this breaks meta-toolchain, which actually has target libc headers
installed under {with-build-sysroot}/opt/... This way features.h is not found
and thus gcc-crosssdk-intermediate thinks that target (e)glibc doesn't support ssp.

Later when building eglibc-nativesdk, undefined reference to "__stack_chk_guard"
occurs which was caused by:

  o eglibc do_configure found that gcc-crosssdk-intermediate supports ssp,
    and thus enable -fstack-protector for nscd

  o eglibc itself supports stack smash proctection for some architectures such
    as i386, x86-64, etc. It's expected to use its own method to provide stack
    protection, instead of relying on gcc. So eglibc rtld.os doesn't export
    __stack_chk_guard to other modules

  o then when installing nscd objects, gcc-crosssdk-intermediate sees the
    flag "-fstack-protector", while it thought this eglibc doesn't implement
    ssp itself, so gcc turns to the alternative to find a valid
    __stack_chk_guard exported. eglibc doesn'g export it, while
    gcc-crosssdk-intermediate itself disables libssp.

Then the undefined reference happens. If enabling libssp for gcc-crosssdk-
intermediate, it may also work-around this issue. But the ideal fix is still
to replace hard coded path with the actual one where target libc gets installed.

glibc-nativesdk doesn't encounter this issue because it thinks gcc doesn't
support ssp, and thus doesn't enable "-fstack-protector" for nscd. Don't know
the reason yet

This fix [BUGID #366]

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
Signed-off-by: Kevin Tian <kevin.tian@intel.com>
meta/recipes-devtools/gcc/gcc-configure-common.inc
meta/recipes-devtools/gcc/gcc-cross-canadian_4.5.0.bb
meta/recipes-devtools/gcc/gcc-cross-initial_4.5.0.bb
meta/recipes-devtools/gcc/gcc-cross-intermediate_4.5.0.bb
meta/recipes-devtools/gcc/gcc-cross_4.5.0.bb
meta/recipes-devtools/gcc/gcc-crosssdk-initial_4.5.0.bb
meta/recipes-devtools/gcc/gcc-crosssdk-intermediate_4.5.0.bb
meta/recipes-devtools/gcc/gcc-crosssdk_4.5.0.bb
meta/recipes-devtools/gcc/gcc-runtime_4.5.0.bb
meta/recipes-devtools/gcc/gcc_4.5.0.bb

index 9dd8feef7c542cd7ac2997fd7e53f8ed9a969bde..43937778f13db6db5d57d0aa77ab83bbf687359f 100644 (file)
@@ -87,6 +87,10 @@ do_configure () {
        export ARCH_FLAGS_FOR_TARGET="${ARCH_FLAGS_FOR_TARGET}"
        (cd ${S} && gnu-configize) || die "failure running gnu-configize"
        
+       # teach gcc to find correct target includedir when checking libc ssp support
+       sed -i 's:^\([  ]*\)glibc_header_dir=\"${with_build_sysroot}/usr/include\":\1glibc_header_dir=\"${with_build_sysroot}${SYSTEMHEADERS}\":g' ${S}/gcc/configure.ac
+       sed -i 's:^\([  ]*\)glibc_header_dir=\"${with_build_sysroot}/usr/include\":\1glibc_header_dir=\"${with_build_sysroot}${SYSTEMHEADERS}\":g' ${S}/gcc/configure
+
        # splice our idea of where the headers live into gcc's world
        echo "NATIVE_SYSTEM_HEADER_DIR = ${SYSTEMHEADERS}" > ${T}/t-oe
        sed 's%^tmake_file=.*$%& ${T}/t-oe%' < ${S}/gcc/Makefile.in >${S}/gcc/Makefile.in.new
index 37a0933bd2030e2451909a62458a4006d3dd464a..4c48b8345d7d04862312385ad7883c5e94ea02f4 100644 (file)
@@ -5,7 +5,7 @@ require gcc-cross-canadian.inc
 require gcc-configure-sdk.inc
 require gcc-package-sdk.inc
 
-PR = "r9"
+PR = "r10"
 
 DEPENDS += "gmp-nativesdk mpfr-nativesdk libmpc-nativesdk elfutils-nativesdk"
 RDEPENDS_${PN} += "mpfr-nativesdk libmpc-nativesdk elfutils-nativesdk"
index 7072fdf4a0269a3a36505878728ca502c9388f28..3ce5ca0a2c7babf16e6e14d1ecb55bd382dd7c69 100644 (file)
@@ -1,5 +1,5 @@
 require gcc-cross_${PV}.bb
 require gcc-cross-initial.inc
 
-PR = "r9"
+PR = "r10"
 
index bb145710c1bb4215b130f364a8464d4d499da99e..0fc54e2cca0a06b275ea5efdcbdfd119dc4295cc 100644 (file)
@@ -1,4 +1,4 @@
 require gcc-cross_${PV}.bb
 require gcc-cross-intermediate.inc
-PR = "r9"
+PR = "r10"
 
index 72032762bfd6d9e2f77afb18a6ae368c7cfdb26d..545beebd1aeff3fad4e0e003369e119927a46633 100644 (file)
@@ -1,4 +1,4 @@
-PR = "r10"
+PR = "r11"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
index c14846a397a86830a0b3601ff6feb6e939c90f7a..69afbae2fc58fc35d0c7f666efab7524d24295e1 100644 (file)
@@ -1,4 +1,4 @@
 require gcc-cross-initial_${PV}.bb
 require gcc-crosssdk-initial.inc
 
-PR = "r9"
+PR = "r10"
index b8204c4dc692f723ec00f7edc449c1ea0f4c7846..934ae644a71a09af10620282268fbd5090ca4c6d 100644 (file)
@@ -1,4 +1,4 @@
 require gcc-cross-intermediate_${PV}.bb
 require gcc-crosssdk-intermediate.inc
 
-PR = "r9"
+PR = "r10"
index df4807d5ad456af0e8efd00631e5b7bc1b203302..48a68bed1a823e4452dd38a7ec6449e17703db65 100644 (file)
@@ -1,4 +1,4 @@
 require gcc-cross_${PV}.bb
 require gcc-crosssdk.inc
 
-PR = "r9"
+PR = "r10"
index 2bfc0df1cb11e1dfeef3189af55796e4b16f5b69..fc3ab0711e68cfcbd93c328d3e121ef6108fc8a0 100644 (file)
@@ -1,4 +1,4 @@
-PR = "r9"
+PR = "r10"
 
 require gcc-${PV}.inc
 require gcc-configure-runtime.inc
index 880c99c8e91487542f7e653ad247db3a1cca5908..7bb61fd790a849c72fb470fce3704189c4c00327 100644 (file)
@@ -1,4 +1,4 @@
-PR = "r9"
+PR = "r10"
 
 require gcc-${PV}.inc
 require gcc-configure-target.inc