AIX - gcc debug mode - segfaults with static data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am using AIX 5.3 and using gcc and binutils (to provide assembler and linker). 

I see a segmentation fault when I run simple C code with a static character array after 
compiling with debugging enabled (via '-g' flag).

I do not see segmentation faults with this code when I do not enable debugging.

Relevant output is as follows :

bash-4.2# oslevel -s
5300-12-04-1119
bash-4.2# rpm -q gcc binutils
gcc-4.8.2-1
binutils-2.24-1
bash-4.2# which as && ls -l $(which as)
/usr/bin/as
lrwxrwxrwx    1 root     system           21 Apr 20 18:44 /usr/bin/as -> /opt/freeware/bin/gas
bash-4.2# which ld && ls -l $(which ld)
/usr/bin/ld
lrwxrwxrwx    1 root     system           21 Apr 21 14:15 /usr/bin/ld -> /opt/freeware/bin/gld
bash-4.2# cat testlink.c
#include <stdio.h>

void printit(const char* input) {
  printf("in printit and input is %s\n", input);
}

const char HELLO[] = "hello.xml";
static const char HELLO_STATIC[] = "hello_static.xml";

int main() {
  printit(HELLO);
  printit(HELLO_STATIC);
  return 0;
}
bash-4.2# gcc -O0 -o testlink testlink.c
bash-4.2# ./testlink 
in printit and input is hello.xml
in printit and input is hello_static.xml
bash-4.2# gcc -g -O0 -o testlink testlink.c
bash-4.2# ./testlink 
in printit and input is hello.xml
Segmentation fault (core dumped)
bash-4.2# 

Any advice gratefully received. 

I realise that this may be a problem with gcc or binutils, but I think that there is a problem?

gcc from http://www.oss4aix.org/download/RPMS/gcc/gcc-4.8.2-1.aix5.3.ppc.rpm

binutils from http://www.oss4aix.org/download/RPMS/binutils/binutils-2.24-1.aix5.1.ppc.rpm

I have read https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46072 but I
think that my case is different - my static data is initialised.

Bob




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux