WinCE support in LD

Nick Clifton nickc@cygnus.com
Wed Feb 23 18:07:00 GMT 2000


Hi Guys,

: >The intention was to have a switch statement that had cases that
: >depended on two values, instead of the default of one value.
: >It's the equivalent of this:
: >
: >	if (bits==16 && shift==16) ...
: >	else if (bits==26 && shift==2) ...
: >
: >What I'd like to see in C is this option:
: >
: >	switch (bits,shift) {
: >          case 16,16 : ...
: >          case 26,2 : ...
: >	}

How about I change it to use amacro like this:


#define BITS_AND_SHIFT(bits, shift) (bits * 1000 | shift)
			    
	  switch BITS_AND_SHIFT (relocs[i]->howto->bitsize,
				 relocs[i]->howto->rightshift)
	    {
	    case BITS_AND_SHIFT (32, 0):
	      reloc_data[total_relocs].type = 3;
	      total_relocs++;
	      break;
	    case BITS_AND_SHIFT (16, 0):
	      reloc_data[total_relocs].type = 2;
	      total_relocs++;
	      break;
	    case BITS_AND_SHIFT (16, 16):
	      reloc_data[total_relocs].type = 4;
	      /* FIXME: we can't know the symbol's right value yet,
		 but we probably can safely assume that CE will relocate
		 us in 64k blocks, so leaving it zero is safe */
	      reloc_data[total_relocs].extra = 0;
	      total_relocs++;
	      break;
	    case BITS_AND_SHIFT (26, 2):
	      reloc_data[total_relocs].type = 5;
	      total_relocs++;
	      break;

Cheers
	Nick


More information about the Binutils mailing list