<commit_before>//!\file link11link.cc
//! \brief Actual work of linking
//!
//!\author <NAME>, Apr 2020
//!

#include "link11.h"


//**********************************************************************
// LinkPsect
//**********************************************************************

//!\brief Dump data structures
//!
//! Debugging routine to display data stored in class
//
void LinkPsect::Dump(
	int Level)	//!< Detail level
{
	std::cout <<
		"  psect module: " <<
		derad504b(module) << "  psect: " <<
		derad504b(name) << "  flag: " <<
		flag << "  length: " <<
		length << "  base: " <<
		std::oct << std::showbase <<
		base << std::endl;

}

//**********************************************************************
// Link
//**********************************************************************

//!\brief Dump out data in structure
//!
//! Debugging routine to display data stored in the class.
//!
void Link::Dump(
	int level)	//!< Level of detail
{
	std::cout << std::endl << "Link" << std::endl;

	//
	// Last module being munged
	//
	std::cout << " Current module: " <<
		derad504b(currentmodule) <<
		std::endl;

	//
	// Display start address
	//
	std::cout << "  Start" << std::endl;
	start.Dump(1);

	//
	// List all modules in list
	//
	psectlist.Dump(level);

	if (currentpsect)
	{
		std::cout << "  Current psect" << std::endl;
		currentpsect->Dump(level);
	}

	std::cout << "Globals" << std::endl;
	globalvars.Dump(level);
	reloclist.Dump(level);
}

//!\brief Pass100 - initialize psect tables
//!
//! Pass to scan through all blocks of data and to set up LinkPsect
//! structures.
//!!
//!\returns ErrorCode
//!
int Link::Pass100(
	ObjectBlock &block)	//!< One block of code from an object file
{
	switch(block.type)
	{
	case BLOCK_GSD:
		//
		// In this pass, we are only interested in global symbol
		// definitions, and psect definitions.
		//
		for (int loop = 0; loop < block.length - 6; loop += 8)
		{
			int attr = block.block[loop + 4];

//			std::cout <<
//				derad504b(block.block + loop) << "  ";

			switch(block.block[loop + 5])
			{
			case GSD_MODNAM:
//				std::cout << "module ";
				memcpy(currentmodule, block.block, 4);
				break;
			case GSD_CSECT:
//				std::cout << "csect  ";
				Pass100Psect(block.block[loop + 5],
					block.block + loop);
				break;
			case GSD_ISN:
				std::cout << "syngol ";
				break;
			case GSD_TA:
//				std::cout << "tran   ";
//std::cout << std::endl << "tran   " << deword(block.block + loop + 6) << std::endl;
				start.setname(block.block + loop);
				start.offset = deword(block.block + loop + 6);
				start.flags = GSN_DEF | GSN_REL;
				start.psect = currentpsect;
				break;
			case GSD_GSN:
//				std::cout << "global ";
				Pass100Gsn(block.block + loop);
				break;
			case GSD_PSECT:
//				std::cout << "psect  ";
				Pass100Psect(block.block[loop + 5],
					block.block + loop);
				break;
			case GSD_IDENT:
				std::cout << "ident  ";
				break;
			case GSD_VSECT:
//				std::cout << "vsect  ";
				Pass100Psect(block.block[loop + 5],
					block.block + loop);
				break;
			default:
				std::cout << "????   ";
				break;<commit_msg>link11 ignore odd transfer addresses<commit_after>//!\file link11link.cc
//! \brief Actual work of linking
//!
//!\author <NAME>, Apr 2020
//!

#include "link11.h"


//**********************************************************************
// LinkPsect
//**********************************************************************

//!\brief Dump data structures
//!
//! Debugging routine to display data stored in class
//
void LinkPsect::Dump(
	int Level)	//!< Detail level
{
	std::cout <<
		"  psect module: " <<
		derad504b(module) << "  psect: " <<
		derad504b(name) << "  flag: " <<
		flag << "  length: " <<
		length << "  base: " <<
		std::oct << std::showbase <<
		base << std::endl;

}

//**********************************************************************
// Link
//**********************************************************************

//!\brief Dump out data in structure
//!
//! Debugging routine to display data stored in the class.
//!
void Link::Dump(
	int level)	//!< Level of detail
{
	std::cout << std::endl << "Link" << std::endl;

	//
	// Last module being munged
	//
	std::cout << " Current module: " <<
		derad504b(currentmodule) <<
		std::endl;

	//
	// Display start address
	//
	std::cout << "  Start" << std::endl;
	start.Dump(1);

	//
	// List all modules in list
	//
	psectlist.Dump(level);

	if (currentpsect)
	{
		std::cout << "  Current psect" << std::endl;
		currentpsect->Dump(level);
	}

	std::cout << "Globals" << std::endl;
	globalvars.Dump(level);
	reloclist.Dump(level);
}

//!\brief Pass100 - initialize psect tables
//!
//! Pass to scan through all blocks of data and to set up LinkPsect
//! structures.
//!!
//!\returns ErrorCode
//!
int Link::Pass100(
	ObjectBlock &block)	//!< One block of code from an object file
{	unsigned int constant;	//!< Value pulled out of block data

	switch(block.type)
	{
	case BLOCK_GSD:
		//
		// In this pass, we are only interested in global symbol
		// definitions, and psect definitions.
		//
		for (int loop = 0; loop < block.length - 6; loop += 8)
		{
			int attr = block.block[loop + 4];

//			std::cout <<
//				derad504b(block.block + loop) << "  ";

			switch(block.block[loop + 5])
			{
			case GSD_MODNAM:
//				std::cout << "module ";
				memcpy(currentmodule, block.block, 4);
				break;
			case GSD_CSECT:
//				std::cout << "csect  ";
				Pass100Psect(block.block[loop + 5],
					block.block + loop);
				break;
			case GSD_ISN:
				std::cout << "syngol ";
				break;
			case GSD_TA:
//				std::cout << "tran   ";
//std::cout << std::endl << "tran   " << deword(block.block + loop + 6) << std::endl;
				constant = deword(block.block + loop + 6);
				if ((constant & 1) == 0)
				{
					//
					// It isn't a real transfer address
					// unless it's even
					//
					start.setname(block.block + loop);
					start.offset = constant;
					start.flags = GSN_DEF | GSN_REL;
					start.psect = currentpsect;
				}
				break;
			case GSD_GSN:
//				std::cout << "global ";
				Pass100Gsn(block.block + loop);
				break;
			case GSD_PSECT:
//				std::cout << "psect  ";
				Pass100Psect(block.block[loop + 5],
					block.block + loop);
				break;
			case GSD_IDENT:
				std::cout << "ident  ";
				break;
			case GSD_VSECT:
//				std::cout << "vsect  ";
				Pass100Psect(block.block[loop + 5],
					block.block + loop);
				break;
			default:
				std::cout << "????   ";
				break;
{'fraction_non_alphanumeric': 0.2515781370284835, 'fraction_numerical': 0.01601231716705158, 'mean_word_length': 2.8805256869773, 'pattern_counts': {'":': 0, '<': 174, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6498410', 'n_tokens_mistral': 2651, 'n_tokens_neox': 2198, 'n_words': 535}