Cross posted from comp.unix.programmer,comp.sys.sgi.misc. Sorry.
In a closely related subject....
Basic Scenerio (SUN SPARC/SunOS 4.1.3 & Solaris):
-------------------------------------------------
I've got an Ada main calling a C function, word(). The C function needs to handle
misaligned data.
It works if I compile like so:
acc -misalign main.c word.c
The following fails to work (with the Sun (Rational/Verdix) Ada compiler):
acc -misalign -c word.c
ada adaMain.a
a.ld adaMain word.o (Where adaMain calls word())
From using the -v option with acc, I see that /apps/lang/SC3.0.1/lib/crt0.o
is replaced by /apps/lang/SC3.0.1/lib/misalign/crt0.o
(For those following along with cc, it's /usr/lib/crt0.o & /usr/lib/misalign/crt0.o)
Question:
---------
What is in .../misalign/crt0.o that I could call from the Ada program to set
up the handling of misaligned data?
Any hints, ideas or straws would be appreciated.
The example code has been cut-down from the original program, or dreamed up
(I didn't do it, can't prove it, nobody saw me... )
Example source code:
adaMain.a
---------
procedure adamain is
procedure cmain;
pragma interface(c, cmain);
pragma interface_name(cmain, "_cmain");
begin
cmain;
end adamain;
word.c
------
#include <stdio.h>
struct {
unsigned byte0 : 8;
unsigned byte1 : 8;
unsigned byte2 : 8;
unsigned byte3 : 8;
unsigned byte4 : 8;
unsigned byte5 : 8;
unsigned byte6 : 8;
unsigned byte7 : 8;
} two_words;
void cmain()
{
unsigned integer;
unsigned *ptr;
unsigned char byte;
unsigned short int halfword;
two_words.byte0 = 0xDE;
two_words.byte1 = 0xAD;
two_words.byte2 = 0xBE;
two_words.byte3 = 0xEF;
two_words.byte4 = 0x60;
two_words.byte5 = 0x0D;
two_words.byte6 = 0xF0;
two_words.byte7 = 0x0D;
byte = two_words.byte3;
halfword = two_words.byte3;
ptr = (unsigned *) ((unsigned) &two_words + 2);
integer = *ptr;
printf ("Made it!\n");
}
main.c
------
main (int argc, char * argv [])
{
cmain ();
}
---
|| Bill Hope || All Opinions are personal and have not ||
|| DSEG Software Automation || been approved by Upper Management. ||
|| Texas Instruments, Inc. || ||
|| voice: 214.995.5618 || Others may have more accurate Facts. ||