e32tools/elf2e32/source/pl_elfexecutable.cpp
changeset 27 3a31ca4b29c4
parent 2 39c28ec933dd
equal deleted inserted replaced
26:d10c1f04b2be 27:3a31ca4b29c4
  1436 {
  1436 {
  1437 	Elf32_Phdr * aHdr;
  1437 	Elf32_Phdr * aHdr;
  1438 
  1438 
  1439 	try {
  1439 	try {
  1440 
  1440 
  1441 		bool limitSymbolFound = false;
  1441 		bool specialSymbolFound = false;
  1442 
  1442 
  1443 		// If Symbol is absolute then assume it came from linker and is a
  1443 		// If Symbol is absolute then assume it came from linker and is a
  1444 		// limit symbol.
  1444 		// limit symbol.
  1445 		if (aSym->st_shndx == SHN_ABS)
  1445 		if (aSym->st_shndx == SHN_ABS)
  1446 		{
  1446 		{
  1447 			aHdr = SegmentFromAbs(aSym->st_value);
  1447 			aHdr = SegmentFromAbs(aSym->st_value);
  1448 		}
  1448 		}
  1449 		else
  1449 		else
  1450 		{
  1450 		{
       
  1451 			// does the symbol point to the address after the end of the code or data segments?
  1451 			if( (iCodeSegmentHdr && aSym->st_value == (iCodeSegmentHdr->p_vaddr + iCodeSegmentHdr->p_memsz)) ||
  1452 			if( (iCodeSegmentHdr && aSym->st_value == (iCodeSegmentHdr->p_vaddr + iCodeSegmentHdr->p_memsz)) ||
  1452 				(iDataSegmentHdr && aSym->st_value == (iDataSegmentHdr->p_vaddr + iDataSegmentHdr->p_memsz)) )
  1453 				(iDataSegmentHdr && aSym->st_value == (iDataSegmentHdr->p_vaddr + iDataSegmentHdr->p_memsz)) )
  1453 			{
  1454 			{
  1454 				//If Symbol is a $$Limit symbol, then consider the open boundary.
  1455 				//If Symbol contains $$, it is linker generated so consider the open boundary.
  1455 				String limitstr = iStringTable + aSym->st_name;
  1456 				//e.g. SHT$$INIT_ARRAY$$Limit and sometimes SHT$$INIT_ARRAY$$Base 
  1456 				if (limitstr.rfind("$$Limit",limitstr.length()) != String::npos)
  1457 				String aSymstr = iStringTable + aSym->st_name;
  1457 				{
  1458 				if (aSymstr.rfind("$$",aSymstr.length()) != String::npos)
  1458 					aHdr = SegmentFromAbs(aSym->st_value);
  1459  				{
  1459 					limitSymbolFound = true;
  1460  					aHdr = SegmentFromAbs(aSym->st_value);
  1460 				}
  1461 					specialSymbolFound = true;
       
  1462  				}
       
  1463 
  1461 			}
  1464 			}
  1462 
  1465 
  1463 			if(!limitSymbolFound )
  1466 			if(!specialSymbolFound )
  1464 			{
  1467 			{
  1465 				aHdr = Segment(aSym->st_value);
  1468 				aHdr = Segment(aSym->st_value);
  1466 			}
  1469 			}
  1467 
  1470 
  1468 		}
  1471 		}