Fill the module info segment addresses and sizes.

This commit is contained in:
Unknown W. Brackets 2014-07-13 18:23:30 -07:00
parent 399d4d1ba9
commit 1c7873e2f5
2 changed files with 20 additions and 22 deletions

View file

@ -80,12 +80,10 @@ public:
int GetNumSegments() { return (int)(header->e_phnum); }
int GetNumSections() { return (int)(header->e_shnum); }
const char *GetSectionName(int section);
u8 *GetPtr(u32 offset)
{
u8 *GetPtr(u32 offset) const {
return (u8*)base + offset;
}
u8 *GetSectionDataPtr(int section)
{
u8 *GetSectionDataPtr(int section) const {
if (section < 0 || section >= header->e_shnum)
return 0;
if (sections[section].sh_type != SHT_NOBITS)
@ -93,45 +91,42 @@ public:
else
return 0;
}
u8 *GetSegmentPtr(int segment)
{
u8 *GetSegmentPtr(int segment) const {
return GetPtr(segments[segment].p_offset);
}
u32 GetSectionAddr(SectionID section) {return sectionAddrs[section];}
int GetSectionSize(SectionID section)
{
u32 GetSectionAddr(SectionID section) const {
return sectionAddrs[section];
}
int GetSectionSize(SectionID section) const {
return sections[section].sh_size;
}
SectionID GetSectionByName(const char *name, int firstSection=0); //-1 for not found
u32 GetSegmentPaddr(int segment)
{
u32 GetSegmentPaddr(int segment) const {
return segments[segment].p_paddr;
}
u32 GetSegmentOffset(int segment)
{
u32 GetSegmentOffset(int segment) const {
return segments[segment].p_offset;
}
u32 GetSegmentVaddr(int segment)
{
u32 GetSegmentVaddr(int segment) const {
return segmentVAddr[segment];
}
u32 GetSegmentDataSize(int segment)
{
u32 GetSegmentDataSize(int segment) const {
return segments[segment].p_filesz;
}
u32 GetSegmentMemSize(int segment) const {
return segments[segment].p_memsz;
}
bool DidRelocate() {
bool DidRelocate() const {
return bRelocate;
}
u32 GetVaddr()
{
u32 GetVaddr() const {
return vaddr;
}
u32 GetTotalSize()
{
u32 GetTotalSize() const {
return totalSize;
}

View file

@ -934,6 +934,8 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro
module->nm.data_size = 0;
// TODO: Is summing them up correct? Must not be since the numbers aren't exactly right.
for (int i = 0; i < reader.GetNumSegments(); ++i) {
module->nm.segmentaddr[i] = reader.GetSegmentVaddr(i);
module->nm.segmentsize[i] = reader.GetSegmentMemSize(i);
module->nm.data_size += reader.GetSegmentDataSize(i);
}
module->nm.gp_value = modinfo->gp;
@ -1668,6 +1670,7 @@ void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValu
u32 error;
Module *module = kernelObjects.Get<Module>(moduleId, error);
if (!module) {
INFO_LOG(SCEMODULE, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x): error %08x", moduleId, argsize, argAddr, returnValueAddr, optionAddr, error);
RETURN(error);
return;
} else if (module->isFake) {