This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Compilation flag with GCC 2.8.1


We developed one application using HP-UX 10.20 proprietary C compiler.
Now we are trying compile it using  GCC 2.8.1 and we found a problem
with compilation flags.

HP compiler has +u1 flag we didn't find in GCC compiler.
This option is vital for our code. In fact, skipping it cause the core
dump of our application.

If you would like, try the following example:

1) Use the following file mappa.c

#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>

#define file "systabina.txt"
main()
{
void     *p_map=NULL;
off_t    fsize, pagesize;
int      boot_fd = -1, i;
void     *temp = NULL;
char     *temp_c = NULL;
short    *temp_i = NULL;

if ((boot_fd=open(file, O_RDWR)) < 0)
    printf("Error in file openening\n");

fsize = lseek(boot_fd, 0, SEEK_END);
if(fsize <0)
   printf("ERRORE fsize <0\n");

pagesize = sysconf(_SC_PAGE_SIZE);
p_map = (void *) mmap (NULL,
                      fsize,
                      (PROT_READ|PROT_WRITE),
                      (MAP_FILE|MAP_VARIABLE|MAP_SHARED),
                      boot_fd,0);
if ( p_map == (void *)-1)
   printf("Error in file mapping\n");

  temp_c = ((char *)p_map) + 1;
  printf("char num. 2 = %c\n", *temp_c);

  temp_i = (short *) ((char *) p_map+1);
  printf("short = %hd\n", *temp_i);
}

   This code accesses a txt file, called systabina.txt, one line long
that is:


2) Compile it using HP compiler in this way:
        %> cc +u1 -o mappa mappa.c

3) Run mappa and obtain the following result:
        %> mappa

        char num. 2 = u
        short = 30053

4) Now compile it without +u1 flag and run it
        %> cc -o mappa mappa.c
        %> mappa

        char num. 2 = u
        (Bus error core dumped)

5) If you try with gcc you obtain the same result:
        %> gcc -o mappa mappa.c
        %> mappa

        char num. 2 = u
        (Bus error core dumped)

We would like to find the correspondent flag +u1 for gcc or adding a
define in the code as workaround. We cannot strongly modify the code.
I mean each structure or similar.

Is necessary modify the source code of GCC? How?

Thank you


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]