Mental on Thu, 24 May 2001 20:12:55 -0400


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

Re: [PLUG] RedHat 7.1 glibc2.1 Backward compat - revisited


On Thu, May 24, 2001 at 05:20:01PM -0400, Walt Mankowski wrote:
> On Thu, May 24, 2001 at 04:59:30PM -0400, Mental wrote:
> > The main reason you've never heard of this so much is because its the
> > compilers job to do this. Sure, we could all be men and use punch cards,
> > or manually manipulate the inodes on the disk with a magnet, but I'm lazy.
> > I'd much rather let gcc worry about byte boundaries and alignment. So
> > would lots of other lazy people. Thats what the -m switches are for in gcc
> > :)
> 
> I've run into issues exactly like this on other platforms.  Imagine a
> structure that looks like this:
> 
> struct foo {
> 	char c;
> 	int i;
> }
> 
> It may look like i still start one byte after c, but in fact for
> performance reasons the compiler may decide to insert some filler so
> that i can start on an even-byte or perhaps a 4-byte boundary.  We
> were moving some code from a 16-bit to a 32-bit box, and discovered
> that the compiler now wanted to line up int's on addresses divisible
> by 4 instead of by 2.


Right. Thats exactly the idea. Sometimes the compiler is smart, sometimes
you have to 'help' it. Ideally its something you're insulated from.
Trouble is, a lot of people are ill prepared to deal with the problem when
it bites them. Sort of like endianness....

whee... fun. 

Actually, it is good stuff to know at least on a i-get-the-concept level.

Essentailly programs are just streams of memory addresses. Some os's
prefer to have the pieces of the program divisible by 4 or 8 or
whatever..... so hopefully your comipiler pads out the machine code
properly and you dont segfault...

--
Mental


______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug