This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: ppc map file is unordered


I had the same problem with map files generated for h8300hms target.  So I
have written a program that takes the map file as stdin and outputs to
stdout the sorted map file.
Since I was in a hurry when doing this, it's written in a "straitforward"
manner but here is it and may be it will give ideas to someone to re-write
it in a nicer manner.
I give it "as is" without any warranty that it will work with other map
files than "mines".

Hope this helps.


/*
mapsort.c
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char Tmp[256];
char Lines[256][256];

int 
comp(const void * el1, const void * el2)
{
	return strncmp((char *)el1 + 18, (char *)el2 + 18, 8);
}

int
main(void)
{
	int LineCount, Index;
	
	while(gets(Tmp) != NULL){
		puts(Tmp);
		if(strncmp(Tmp, "Linker script", 13) == 0){
			break;
		}
	}
	LineCount = 0;
	while(gets(Tmp) != NULL){
		if(
			(strlen(Tmp) == 0)
			||
			(strncmp(Tmp, "  ", 2) != 0)
		){
			if(LineCount > 1){
				qsort(Lines, LineCount, 256, comp);
			}
			for(Index = 0; Index < LineCount;
puts(Lines[Index++]));
			puts(Tmp);
			LineCount = 0;
			continue;
		}
		if(Tmp[3] == ' '){
			strcpy(Lines[LineCount++], Tmp);
		}
	}
	return 0;
}

#########################
This message has been scanned for viruses with F-Secure Anti-Virus for
Microsoft Exchange and it has been found clean.

For more information about computer viruses, connect to
http://www.F-Secure.com/vir-info/.
#########################

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]