Java Code Examples for ghidra.program.model.lang.Language#getDefaultDataSpace()

The following examples show how to use ghidra.program.model.lang.Language#getDefaultDataSpace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PIC30_ElfExtension.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public AddressSpace getPreferredSegmentAddressSpace(ElfLoadHelper elfLoadHelper,
		ElfProgramHeader elfProgramHeader) {
	Language language = elfLoadHelper.getProgram().getLanguage();
	if (isDataLoad(elfProgramHeader)) {
		return language.getDefaultDataSpace();
	}
	return language.getDefaultSpace();
}
 
Example 2
Source File: PIC30_ElfExtension.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public AddressSpace getPreferredSectionAddressSpace(ElfLoadHelper elfLoadHelper,
		ElfSectionHeader elfSectionHeader) {
	Language language = elfLoadHelper.getProgram().getLanguage();
	if (isDataLoad(elfSectionHeader)) {
		return language.getDefaultDataSpace();
	}
	return language.getDefaultSpace();
}
 
Example 3
Source File: DWARFAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean getDefaultEnablement(Program program) {
	// TODO: DWARF implementation needs improvements to handle Harvard Architectures properly
	// Currently unable to produce addresses which should refer to data space resulting in
	// improperly placed symbols, etc.
	Language language = program.getLanguage();
	return language.getDefaultSpace() == language.getDefaultDataSpace();
}
 
Example 4
Source File: OmfSegmentHeader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * @param language is the Program language for this binary
 * @return the starting Address for this segment
 */
public Address getAddress(Language language) {
	AddressSpace addrSpace;

	if (isCode) {
		addrSpace = language.getDefaultSpace();
	} else {
		addrSpace = language.getDefaultDataSpace();
	}
	return addrSpace.getAddress(vma);		
}
 
Example 5
Source File: CoffSectionHeader.java    From ghidra with Apache License 2.0 2 votes vote down vote up
/**
 * Convert address offset to an Address object.  The default data space (defined by pspec)
 * will be used if section is null or corresponds to a data section.  The language default
 * space (defined by slaspec) will be used for all non-data sections.  If pspec does not 
 * specify a default data space, the default language space is used.
 * @param language
 * @param offset address offset (byte offset assumed if section is null or is not explicitly
 * byte aligned, otherwise word offset assumed).
 * @param section section which contains the specified offset or null (data space assumed)
 * @return address object
 */
public static Address getAddress(Language language, long offset, CoffSectionHeader section) {
	boolean isData = section == null || section.isData();
	AddressSpace space = isData ? language.getDefaultDataSpace() : language.getDefaultSpace();
	return space.getAddress(offset * getOffsetUnitSize(language, section));
}