Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!cs.utexas.edu!uunet!mcsun!ukc!icdoc!inmos!frogland!des From: des@frogland.inmos.co.uk (David Shepherd) Newsgroups: comp.os.minix Subject: Re: The continuing saga of Minix 'ar' on the SPARC Keywords: Almost there.... Message-ID: <12887@wraxall.inmos.co.uk> Date: 10 Jan 91 11:08:58 GMT References: <1991Jan9.151828@mobius.Viewlogic.COM> Sender: news@inmos.co.uk Reply-To: des@frogland.inmos.co.uk (David Shepherd) Organization: INMOS architecture group Lines: 50 In article <1991Jan9.151828@mobius.Viewlogic.COM>, greg@mobius.Viewlogic.COM (Gregory Larkin) writes: |> Well, the fight continues to get a SPARC executable to read a Minix |> .a file. |> |> However, when the first header structure is read out of the .a file, |> most everything in it does not come in correctly. |> Here's the struct for .a header: .... let me guess .... the header gets read in by a command like fread(f, &hdr, sizeof (struct ar_hdr), 1); if so this is your problem. This is *NON-PORTABLE*. The Sparc C compiler does (clever?) things with the positioning of elements inside a struct .... in particular it will align entries to word boundaries if there are word lengthed items in it. So in |> struct ar_hdr { |> char ar_name[14]; |> long ar_date; |> char ar_uid; |> char ar_gid; |> int ar_mode; |> long ar_size; |> }; The Sparc C compiler sees the struct as being 14 bytes of ar_name 2 bytes padding 4 bytes of ar_date 1 byte of ar_uid 1 byte of ar_gid 2 bytes padding 4 bytes of ar_mode <- ints are 32 bits here 4 bytes of ar_size Hence reading in a struct which probably doesn't align components (and probably has 16 bit ints) causes rubbish to be seen in the struct components. The fix is probably to read in the struct as an array of bytes and assign the components by hand :-( -- -------------------------------------------------------------------------- david shepherd: des@inmos.co.uk or des@inmos.com tel: 0454-616616 x 529 inmos ltd, 1000 aztec west, almondsbury, bristol, bs12 4sq phevbfvgl xvyyrq gur png