alignment

alignment

Post by Martin Str|mber » Mon, 23 Dec 2002 21:45:50



I see that lib/gcc-lib/djgpp/3.2/djgpp-x.djl aligns the sections on
256 bytes. Why isn't 128 sufficient.

If I don't use any floating point, MMX or SSE instructions would 8
bytes alignment be sufficient (worst case should be long long)?

Right,

                                                MartinS

 
 
 

1. Alignment problem

When I execute the small program

#include <stdio.h>
#include <stdlib.h>

int main(void) {
   void *ptr;

   ptr = malloc(1024);
   if (((int) ptr) & 7) {
      printf(" ptr %p not 8-byte aligned.\n", ptr);
   } else {
      printf(" ptr %p     8-byte aligned.\n", ptr);
   }
   free(ptr);
   return 0;

I get output like

 ptr 8f4e4 not 8-byte aligned.

about half the time.  I am currently running gcc 2.95.3, binutils
2.11.2, CWSDPMI r5 under PC-DOS 6.3.  The problem also exists in a DOS
box under Win95 (where CWSDPMI is not being used).

I am calling gcc with the following options:

   -O2
   -march=pentium
   -Wall
   -fomit-frame-pointer

I thought that this alignment problem had been solved in gcc 2.95 and
binutils 2.9.1.  What should I do to diagnose this problem further?

-Eric Rudd

2. Items wanted

3. Alignment fault signals

4. 2nd NTFS Boot Sector unwritable

5. Section alignment

6. Windows 2000 Professional Problems!

7. malloc() and assumptions about alignment

8. Inbox in Name not Date order?

9. Again: data alignment

10. Data Alignment for Optimal Access

11. -mpentiumpro alignment & PGCC

12. Alignment