mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-28 08:50:22 +00:00
arm32: parse dwarf
This commit is contained in:
parent
d5b5734ef9
commit
02986aed38
File diff suppressed because it is too large
Load Diff
@ -38,16 +38,20 @@ describe('test ELFParser', () => {
|
|||||||
console.log('symbol', index, symbol.info, symbol.other, symbol.name, symbol.value.toString(16));
|
console.log('symbol', index, symbol.info, symbol.other, symbol.name, symbol.value.toString(16));
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
assert.strictEqual(22, elfParser.sectionHeaders.length);
|
assert.strictEqual(21, elfParser.sectionHeaders.length);
|
||||||
assert.strictEqual(31, elfParser.getSymbols().length);
|
assert.strictEqual(29, elfParser.getSymbols().length);
|
||||||
assert.ok(elfParser.sectionHeaders.find((section) => section.name === '.text') != null);
|
assert.ok(elfParser.sectionHeaders.find((section) => section.name === '.text') != null);
|
||||||
assert.ok(elfParser.getSymbols().find((symbol) => symbol.name === 'main') != null);
|
assert.ok(elfParser.getSymbols().find((symbol) => symbol.name === 'main') != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse DWARF info', () => {
|
it('should parse DWARF info', () => {
|
||||||
const dwarf = new DWARFParser(elfParser);
|
const dwarf = new DWARFParser(elfParser);
|
||||||
|
assert.strictEqual(2, dwarf.units.length);
|
||||||
|
const cu = dwarf.units[0];
|
||||||
|
// TODO: check info content
|
||||||
|
const li = dwarf.lineInfos[0];
|
||||||
|
assert.strictEqual('crt0.c', li.files[1].name);
|
||||||
/*
|
/*
|
||||||
const info = dwarf.getCompilationUnits()[0];
|
|
||||||
assert.ok(info != null);
|
assert.ok(info != null);
|
||||||
assert.ok(info!.lineNumberProgram != null);
|
assert.ok(info!.lineNumberProgram != null);
|
||||||
assert.ok(info!.lineNumberProgram!.length > 0);
|
assert.ok(info!.lineNumberProgram!.length > 0);
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -20,11 +20,11 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ELFParser } from "../../common/binutils";
|
import { DWARFParser, ELFParser } from "../../common/binutils";
|
||||||
import { hex } from "../../common/util";
|
import { hex } from "../../common/util";
|
||||||
import { WASIFilesystem } from "../../common/wasi/wasishim";
|
import { WASIFilesystem } from "../../common/wasi/wasishim";
|
||||||
import { CodeListingMap, SourceLine, WorkerError, WorkerResult } from "../../common/workertypes";
|
import { CodeListingMap, SourceLine, WorkerError, WorkerResult } from "../../common/workertypes";
|
||||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, populateFiles, putWorkFile, anyTargetChanged, getPrefix, getWorkFileAsString, populateExtraFiles } from "../builder";
|
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, populateFiles, putWorkFile, anyTargetChanged, getPrefix, getWorkFileAsString, populateExtraFiles, processEmbedDirective } from "../builder";
|
||||||
import { makeErrorMatcher, re_crlf } from "../listingutils";
|
import { makeErrorMatcher, re_crlf } from "../listingutils";
|
||||||
import { loadWASIFilesystemZip } from "../wasiutils";
|
import { loadWASIFilesystemZip } from "../wasiutils";
|
||||||
import { loadNative, moduleInstFn, execMain, emglobal, EmscriptenModule } from "../wasmutils";
|
import { loadNative, moduleInstFn, execMain, emglobal, EmscriptenModule } from "../wasmutils";
|
||||||
@ -293,7 +293,7 @@ export async function compileARMTCC(step: BuildStep): Promise<BuildStepResult> {
|
|||||||
//'-std=c11',
|
//'-std=c11',
|
||||||
'-funsigned-char',
|
'-funsigned-char',
|
||||||
//'-Wwrite-strings',
|
//'-Wwrite-strings',
|
||||||
'-gdwarf',
|
'-gdwarf-2',
|
||||||
'-o', objpath];
|
'-o', objpath];
|
||||||
if (params.define) {
|
if (params.define) {
|
||||||
params.define.forEach((x) => args.push('-D' + x));
|
params.define.forEach((x) => args.push('-D' + x));
|
||||||
@ -313,7 +313,15 @@ export async function compileARMTCC(step: BuildStep): Promise<BuildStepResult> {
|
|||||||
});
|
});
|
||||||
populateExtraFiles(step, FS, params.extra_compile_files);
|
populateExtraFiles(step, FS, params.extra_compile_files);
|
||||||
|
|
||||||
populateFiles(step, FS);
|
populateFiles(step, FS, {
|
||||||
|
mainFilePath: step.path,
|
||||||
|
processFn: (path, code) => {
|
||||||
|
if (typeof code === 'string') {
|
||||||
|
code = processEmbedDirective(code);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
});
|
||||||
execMain(step, armtcc, args);
|
execMain(step, armtcc, args);
|
||||||
if (errors.length)
|
if (errors.length)
|
||||||
return { errors: errors };
|
return { errors: errors };
|
||||||
@ -347,7 +355,7 @@ export async function linkARMTCC(step: BuildStep): Promise<WorkerResult> {
|
|||||||
var args = ['-L.', '-nostdlib', '-nostdinc',
|
var args = ['-L.', '-nostdlib', '-nostdinc',
|
||||||
'-Wl,--oformat=elf32-arm',
|
'-Wl,--oformat=elf32-arm',
|
||||||
//'-Wl,-section-alignment=0x100000',
|
//'-Wl,-section-alignment=0x100000',
|
||||||
'-gdwarf',
|
'-gdwarf-2',
|
||||||
'-o', objpath];
|
'-o', objpath];
|
||||||
if (params.define) {
|
if (params.define) {
|
||||||
params.define.forEach((x) => args.push('-D' + x));
|
params.define.forEach((x) => args.push('-D' + x));
|
||||||
@ -410,10 +418,31 @@ export async function linkARMTCC(step: BuildStep): Promise<WorkerResult> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const listings: CodeListingMap = {};
|
||||||
|
const dwarf = new DWARFParser(elfparser);
|
||||||
|
dwarf.lineInfos.forEach((lineInfo) => {
|
||||||
|
lineInfo.files.forEach((file) => {
|
||||||
|
if (!file || !file.lines) return;
|
||||||
|
file.lines.forEach((line) => {
|
||||||
|
const filename = line.file;
|
||||||
|
const offset = line.address;
|
||||||
|
const path = getPrefix(filename) + '.lst';
|
||||||
|
const linenum = line.line;
|
||||||
|
let lst = listings[path];
|
||||||
|
if (lst == null) { lst = listings[path] = { lines: [] }; }
|
||||||
|
lst.lines.push({
|
||||||
|
path,
|
||||||
|
line: linenum,
|
||||||
|
offset
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//console.log(listings);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
output: rom, //.slice(0x34),
|
output: rom, //.slice(0x34),
|
||||||
//listings: listings,
|
listings: listings,
|
||||||
errors: errors,
|
errors: errors,
|
||||||
symbolmap: symbolmap,
|
symbolmap: symbolmap,
|
||||||
segments: segments
|
segments: segments
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user