Merge with ba6179dfe20e3a949de0612e01bd71d0e6918b78
authorl12wang
Thu, 08 Oct 2009 18:13:59 -0500
changeset 100 6e8bead0f126
parent 99 83ae0d82da3b (diff)
parent 98 ba6179dfe20e (current diff)
child 101 133ef3ae697b
Merge with ba6179dfe20e3a949de0612e01bd71d0e6918b78
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java	Thu Oct 08 17:58:14 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java	Thu Oct 08 18:13:59 2009 -0500
@@ -644,15 +644,24 @@
 
 	public Symbol[] getSymbols() throws IOException {
 		if (symbolTable == null) {
+			SectionHeader[] secHeaders = getSectionHeaders();
+			NTOptionalHeader ntHeader = getNTOptionalHeader();
+
 			RandomAccessFile accessFile = getRandomAccessFile();
 			long offset = fileHeader.f_symptr;
 			symbolTable = new Symbol[fileHeader.f_nsyms];
 			for (int i = 0; i < symbolTable.length; i++, offset += Symbol.SYMSZ) {
-				symbolTable[i] = new Symbol(accessFile, offset);
-				NTOptionalHeader ntHeader = getNTOptionalHeader();
-				// FIXME: What is this again ?
+				Symbol newSym = new Symbol(accessFile, offset);
+				
+				// Now convert section offset of the symbol to image offset.
+				if (newSym.n_scnum >= 1 && newSym.n_scnum <= secHeaders.length)	// valid section #
+					newSym.n_value += secHeaders[newSym.n_scnum-1].s_vaddr;
+				
+				// convert to absolute address.
 				if (ntHeader != null)
-					symbolTable[i].n_value += ntHeader.ImageBase + ntHeader.FileAlignment;
+					newSym.n_value += ntHeader.ImageBase;
+				
+				symbolTable[i] = newSym;
 			}				
 		}
 		return symbolTable;