Author: arty
Date: Mon Jun 18 02:05:45 2007
New Revision: 27219
URL:
http://svn.reactos.org/svn/reactos?rev=27219&view=rev
Log:
Fix getting .idata and .edata addresses.
Keep freeldr linkage up to date.
ldscript -- don't sort .idata$2 so we get modules linked in natural
order.
Modified:
branches/powerpc/reactos/tools/ppc-build/elfpe/compdvr.cpp
branches/powerpc/reactos/tools/ppc-build/elfpe/header.cpp
branches/powerpc/reactos/tools/ppc-build/elfpe/header.h
branches/powerpc/reactos/tools/ppc-build/elfpe/objectfile.cpp
branches/powerpc/reactos/tools/ppc-build/elfpe/objectfile.h
branches/powerpc/reactos/tools/ppc-build/ldscript
branches/powerpc/reactos/tools/ppc.lost+found/link-freeldr
Modified: branches/powerpc/reactos/tools/ppc-build/elfpe/compdvr.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/elfpe/compdvr.cpp (original)
+++ branches/powerpc/reactos/tools/ppc-build/elfpe/compdvr.cpp Mon Jun 18 02:05:45 2007
@@ -169,6 +169,8 @@
args.insert(args.begin()+2,ldscript);
args.insert(args.begin()+1,"--emit-relocs");
args.insert(args.begin()+1,"-dc");
+ args.insert(args.begin()+1,"-z");
+ args.insert(args.begin()+2,"defs");
args.insert(args.begin()+1,"-r");
for( size_t i = 0; i < args.size(); i++ ) {
Modified: branches/powerpc/reactos/tools/ppc-build/elfpe/header.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/elfpe/header.cpp (original)
+++ branches/powerpc/reactos/tools/ppc-build/elfpe/header.cpp Mon Jun 18 02:05:45 2007
@@ -83,9 +83,9 @@
le32write_postinc(dataptr, 0);
le32write_postinc(dataptr, 10); // # Directories
// "Directories"
- le32pwrite_postinc(dataptr, getExportInfo());
- le32pwrite_postinc(dataptr, getImportInfo());
- le32pwrite_postinc(dataptr, getResourceInfo());
+ le32pwrite_postinc(dataptr, getExportInfo(sectionRvaSet));
+ le32pwrite_postinc(dataptr, getImportInfo(sectionRvaSet));
+ le32pwrite_postinc(dataptr, getResourceInfo(sectionRvaSet));
le32pwrite_postinc(dataptr, getExceptionInfo());
le32pwrite_postinc(dataptr, getSecurityInfo());
le32pwrite_postinc(dataptr, getRelocInfo());
@@ -155,28 +155,37 @@
return IMAGE_FILE_MACHINE_POWERPCBE; /* for now */
}
-u32pair_t getNamedSectionInfo(ElfObjectFile *eof, const std::string &name)
+u32pair_t getNamedSectionInfo(ElfObjectFile *eof, const
std::vector<section_mapping_t> &mapping, const std::string &name)
{
const ElfObjectFile::Section *sect = eof->getNamedSection(name);
+ uint32_t sectaddr;
+ int i;
+
if(sect)
- return std::make_pair(sect->getStartRva(), sect->logicalSize());
- else
- return std::make_pair(0,0);
-}
-
-u32pair_t ElfPeHeader::getExportInfo() const
-{
- return getNamedSectionInfo(eof, ".edata");
-}
-
-u32pair_t ElfPeHeader::getImportInfo() const
-{
- return getNamedSectionInfo(eof, ".idata");
-}
-
-u32pair_t ElfPeHeader::getResourceInfo() const
-{
- return getNamedSectionInfo(eof, ".rsrc");
+ {
+ for(i = 0; i < mapping.size(); i++)
+ if(mapping[i].index == sect->getNumber())
+ {
+ return std::make_pair
+ (mapping[i].rva, sect->logicalSize());
+ }
+ }
+ return std::make_pair(0,0);
+}
+
+u32pair_t ElfPeHeader::getExportInfo(const std::vector<section_mapping_t>
&mapping) const
+{
+ return getNamedSectionInfo(eof, mapping, ".edata");
+}
+
+u32pair_t ElfPeHeader::getImportInfo(const std::vector<section_mapping_t>
&mapping) const
+{
+ return getNamedSectionInfo(eof, mapping, ".idata");
+}
+
+u32pair_t ElfPeHeader::getResourceInfo(const std::vector<section_mapping_t>
&mapping) const
+{
+ return getNamedSectionInfo(eof, mapping, ".rsrc");
}
u32pair_t ElfPeHeader::getExceptionInfo() const
@@ -215,7 +224,7 @@
}
uint32_t ElfPeHeader::getEntryPoint
-(const std::vector<ElfPeHeader::section_mapping_t> &secmap,
+(const std::vector<section_mapping_t> &secmap,
const ElfObjectFile::Symbol *entry) const
{
if(entry == NULL) return computeSize();
Modified: branches/powerpc/reactos/tools/ppc-build/elfpe/header.h
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/elfpe/header.h (original)
+++ branches/powerpc/reactos/tools/ppc-build/elfpe/header.h Mon Jun 18 02:05:45 2007
@@ -6,6 +6,18 @@
#include "pedef.h"
#include "util.h"
#include "objectfile.h"
+
+typedef struct section_mapping_t {
+ const ElfObjectFile::Section *section;
+ uint32_t rva;
+ int index;
+
+ section_mapping_t
+ (const ElfObjectFile::Section *sect, uint32_t rva, int index) :
+ section(sect), rva(rva), index(index) { }
+ section_mapping_t(const section_mapping_t &other) :
+ section(other.section), rva(other.rva), index(other.index) { }
+} section_mapping_t;
class ElfPeHeader {
public:
@@ -24,27 +36,15 @@
const ElfObjectFile::secdata_t &getData() const;
private:
- typedef struct section_mapping_t {
- const ElfObjectFile::Section *section;
- uint32_t rva;
- int index;
-
- section_mapping_t
- (const ElfObjectFile::Section *sect, uint32_t rva, int index) :
- section(sect), rva(rva), index(index) { }
- section_mapping_t(const section_mapping_t &other) :
- section(other.section), rva(other.rva), index(other.index) { }
- } section_mapping_t;
-
void createHeaderSection();
uint32_t getSectionRvas(std::vector<section_mapping_t> &rvas) const;
uint32_t getEntryPoint(const std::vector<section_mapping_t> &rvas, const
ElfObjectFile::Symbol *entry) const;
int computeSize() const;
int getExeFlags() const { return 0; }
int getDllFlags() const { return dll ? IMAGE_FILE_DLL : 0; }
- u32pair_t getExportInfo() const;
- u32pair_t getImportInfo() const;
- u32pair_t getResourceInfo() const;
+ u32pair_t getExportInfo(const std::vector<section_mapping_t> &rvas) const;
+ u32pair_t getImportInfo(const std::vector<section_mapping_t> &rvas) const;
+ u32pair_t getResourceInfo(const std::vector<section_mapping_t> &rvas)
const;
u32pair_t getExceptionInfo() const;
u32pair_t getSecurityInfo() const;
u32pair_t getRelocInfo() const;
Modified: branches/powerpc/reactos/tools/ppc-build/elfpe/objectfile.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/elfpe/objectfile.cpp (original)
+++ branches/powerpc/reactos/tools/ppc-build/elfpe/objectfile.cpp Mon Jun 18 02:05:45
2007
@@ -28,7 +28,7 @@
{
s = elf_nextscn(elfHeader, s);
if(!s) break;
- sect = new Section(*this, s);
+ sect = new Section(*this, i, s);
sections.push_back(sect);
sections_by_name.insert(std::make_pair(sect->getName(), sect));
}
Modified: branches/powerpc/reactos/tools/ppc-build/elfpe/objectfile.h
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/elfpe/objectfile.h (original)
+++ branches/powerpc/reactos/tools/ppc-build/elfpe/objectfile.h Mon Jun 18 02:05:45 2007
@@ -24,11 +24,12 @@
class Section {
public:
Section(const Section &other) :
- obj(other.obj), section(other.section), have_data(false) {
+ obj(other.obj), section(other.section), have_data(false),
+ number(other.number) {
e32shdr = elf32_getshdr(section);
}
- Section(ElfObjectFile &obj, Elf_Scn *sechdr) :
- obj(&obj), section(sechdr), have_data(false) {
+ Section(ElfObjectFile &obj, int number, Elf_Scn *sechdr) :
+ obj(&obj), section(sechdr), have_data(false), number(number) {
e32shdr = elf32_getshdr(section);
}
Section &operator = (const Section &other) {
@@ -36,6 +37,7 @@
have_data = false;
section = other.section;
e32shdr = other.e32shdr;
+ number = other.number;
}
operator bool () { return !!section; }
std::string getName() const {
@@ -44,6 +46,10 @@
int getType() const {
return e32shdr->sh_type;
+ }
+
+ int getNumber() const {
+ return number;
}
int getLink() const {
@@ -80,6 +86,7 @@
private:
const ElfObjectFile *obj;
+ int number;
Elf_Scn *section;
Elf32_Shdr *e32shdr;
mutable bool have_data;
Modified: branches/powerpc/reactos/tools/ppc-build/ldscript
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/ldscript (original)
+++ branches/powerpc/reactos/tools/ppc-build/ldscript Mon Jun 18 02:05:45 2007
@@ -28,7 +28,7 @@
}
.idata :
{
- SORT(*)(.idata$2)
+ *(.idata$2)
SORT(*)(.idata$3)
LONG(0); LONG(0); LONG(0); LONG(0); LONG(0);
SORT(*)(.idata$4)
Modified: branches/powerpc/reactos/tools/ppc.lost+found/link-freeldr
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc.lost%…
==============================================================================
--- branches/powerpc/reactos/tools/ppc.lost+found/link-freeldr (original)
+++ branches/powerpc/reactos/tools/ppc.lost+found/link-freeldr Mon Jun 18 02:05:45 2007
@@ -53,6 +53,7 @@
obj-ppc/boot/freeldr/freeldr/arch/powerpc/mach.o \
obj-ppc/boot/freeldr/freeldr/arch/powerpc/ofw.o \
obj-ppc/boot/freeldr/freeldr/arch/powerpc/mboot.o \
+ obj-ppc/boot/freeldr/freeldr/arch/powerpc/loader.o \
obj-ppc/boot/freeldr/freeldr/arch/powerpc/prep.o \
obj-ppc/boot/freeldr/freeldr/arch/powerpc/prep_ide.o \
obj-ppc/boot/freeldr/freeldr/arch/powerpc/prep_pci.o \