How do I get C++ programs to link with gcc's stack protector feature on AIX?

核能气质少年 提交于 2019-12-13 17:55:43

问题


I'm a bit of an AIX newbie. I'm trying to compile a program using gcc's stack protector feature. I installed gcc on server using pware's GCC package and I can compile a sample program like:

#include <stdio.h>

int main(int argc,char **argv)
{
  printf("hello world\n");

  return 0;
}

When I turn on stack-protector though, I get: g++ -fstack-protector-all main.cpp collect2: library libssp_nonshared not found

I've been hunting on google for a solution to this and it seems like my libc needs to have some stuff built into that mine doesn't. Is there a package out there that includes a libc with the stack protection builtin?

g++ -v returns

Using built-in specs.
Target: powerpc-ibm-aix5.3.0.0
Configured with: ../stage/gcc-4.2.4/configure --disable-shared --enable-threads=posix --prefix=/opt/pware --with-long-double-128 --with-mpfr=/opt/pware --with-gmp=/opt/pware
Thread model: aix
gcc version 4.2.4

I can not find libssp_nonshared.a on the system -- is there an additional package I need to install or should it have come with the gcc package?


回答1:


This has nothing to do with libc: your GCC installation is missing libssp_nonshared.a library.

What does your "gcc --version" say? It may have been configured with --disable-libssp option (in which case you can't use the stack protection instrumentation).

Update:
I just looked in gcc-4.3.0/configure:

 powerpc-*-aix*)
    noconfigdirs="$noconfigdirs gprof target-libgloss target-libssp ${libgcj}"
    ;;

I am about 99% sure this means that libssp (and therefore -fstack-protector) is not available for your platform. Sorry :-(



来源:https://stackoverflow.com/questions/1348895/how-do-i-get-c-programs-to-link-with-gccs-stack-protector-feature-on-aix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!