make elphin shut up in pipelines
This commit is contained in:
parent
d33c09a1ab
commit
b7c527394d
6 changed files with 27 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
|||
.{
|
||||
.name = "elphin",
|
||||
.version = "0.1.5",
|
||||
.version = "0.1.6",
|
||||
.minimum_zig_version = "0.12.0",
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
|
|
|
@ -60,7 +60,7 @@ fn make(step: *std.Build.Step, _: *std.Progress.Node) !void {
|
|||
defer output.close();
|
||||
|
||||
// Run conversion
|
||||
try lib.convert(input, output);
|
||||
try lib.convert(input, output, false);
|
||||
|
||||
// Copy file to destination
|
||||
const cwd = std.fs.cwd();
|
||||
|
|
10
src/dol.zig
10
src/dol.zig
|
@ -83,7 +83,7 @@ pub fn createDOLMapping(segments: elf.ELFSegments) DolMap {
|
|||
return dolMap;
|
||||
}
|
||||
|
||||
pub fn writeDOL(map: DolMap, input: std.fs.File, output: std.fs.File) !void {
|
||||
pub fn writeDOL(map: DolMap, input: std.fs.File, output: std.fs.File, verbose: bool) !void {
|
||||
const reader = input.reader();
|
||||
const writer = output.writer();
|
||||
|
||||
|
@ -106,7 +106,9 @@ pub fn writeDOL(map: DolMap, input: std.fs.File, output: std.fs.File) !void {
|
|||
try output.seekTo(map.header.textOffsets[i]);
|
||||
|
||||
// Copy segment
|
||||
std.log.debug("Copying text segment {d} at 0x{x} -> 0x{x}", .{ i, map.header.textAddress[i], map.header.textOffsets[i] });
|
||||
if (verbose) {
|
||||
std.log.debug("Copying text segment {d} at 0x{x} -> 0x{x}", .{ i, map.header.textAddress[i], map.header.textOffsets[i] });
|
||||
}
|
||||
try fifo.pump(&limitedReader, writer);
|
||||
}
|
||||
|
||||
|
@ -122,7 +124,9 @@ pub fn writeDOL(map: DolMap, input: std.fs.File, output: std.fs.File) !void {
|
|||
try output.seekTo(map.header.dataOffsets[i]);
|
||||
|
||||
// Copy segment
|
||||
std.log.debug("Copying data segment {d} at 0x{x} -> 0x{x}", .{ i, map.header.dataAddress[i], map.header.dataOffsets[i] });
|
||||
if (verbose) {
|
||||
std.log.debug("Copying data segment {d} at 0x{x} -> 0x{x}", .{ i, map.header.dataAddress[i], map.header.dataOffsets[i] });
|
||||
}
|
||||
try fifo.pump(&limitedReader, writer);
|
||||
}
|
||||
}
|
||||
|
|
21
src/elf.zig
21
src/elf.zig
|
@ -78,7 +78,7 @@ pub const ELFSegments = struct {
|
|||
bssSize: u32,
|
||||
};
|
||||
|
||||
pub fn readELF(file: std.fs.File) !ELFSegments {
|
||||
pub fn readELF(file: std.fs.File, verbose: bool) !ELFSegments {
|
||||
// Create segment map
|
||||
var elfMap: ELFSegments = .{
|
||||
.entryPoint = undefined,
|
||||
|
@ -156,10 +156,14 @@ pub fn readELF(file: std.fs.File) !ELFSegments {
|
|||
if (programHeader.p_filesz < programHeader.p_memsz) {
|
||||
// Add as BSS segment of whatever is left between the file and memory sizes
|
||||
addOrExtendBSS(&elfMap, programHeader.p_paddr + programHeader.p_filesz, programHeader.p_memsz - programHeader.p_filesz);
|
||||
std.log.debug("Found bss segment (TEXT) at 0x{x}", .{programHeader.p_paddr + programHeader.p_filesz});
|
||||
if (verbose) {
|
||||
std.log.debug("Found bss segment (TEXT) at 0x{x}", .{programHeader.p_paddr + programHeader.p_filesz});
|
||||
}
|
||||
}
|
||||
|
||||
std.log.debug("Found text segment at 0x{x}", .{programHeader.p_vaddr});
|
||||
if (verbose) {
|
||||
std.log.debug("Found text segment at 0x{x}", .{programHeader.p_vaddr});
|
||||
}
|
||||
|
||||
elfMap.text[elfMap.textCount] = .{
|
||||
.address = programHeader.p_paddr,
|
||||
|
@ -170,11 +174,12 @@ pub fn readELF(file: std.fs.File) !ELFSegments {
|
|||
elfMap.textCount += 1;
|
||||
} else {
|
||||
// DATA or BSS segment
|
||||
|
||||
// TODO: ????
|
||||
if (programHeader.p_filesz == 0) {
|
||||
addOrExtendBSS(&elfMap, programHeader.p_paddr, programHeader.p_memsz);
|
||||
std.log.debug("Found bss segment (DATA) at 0x{x}", .{programHeader.p_vaddr});
|
||||
|
||||
if (verbose) {
|
||||
std.log.debug("Found bss segment (DATA) at 0x{x}", .{programHeader.p_vaddr});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -183,7 +188,9 @@ pub fn readELF(file: std.fs.File) !ELFSegments {
|
|||
return ELFError.TooManyDataSegments;
|
||||
}
|
||||
|
||||
std.log.debug("Found data segment at 0x{x}", .{programHeader.p_vaddr});
|
||||
if (verbose) {
|
||||
std.log.debug("Found data segment at 0x{x}", .{programHeader.p_vaddr});
|
||||
}
|
||||
|
||||
elfMap.data[elfMap.dataCount] = .{
|
||||
.address = programHeader.p_paddr,
|
||||
|
|
|
@ -10,13 +10,13 @@ pub const writeDOL = dol.writeDOL;
|
|||
|
||||
/// Converts an ELF file to a DOL file.
|
||||
/// `input` and `output` must be open files.
|
||||
pub fn convert(input: anytype, output: anytype) !void {
|
||||
pub fn convert(input: anytype, output: anytype, verbose: bool) !void {
|
||||
// Read input
|
||||
const map = try elf.readELF(input);
|
||||
const map = try elf.readELF(input, verbose);
|
||||
|
||||
// Align segments to 64 byte boundaries
|
||||
const dolMap = dol.createDOLMapping(map);
|
||||
|
||||
// Write header and copy over segments from input
|
||||
try dol.writeDOL(dolMap, input, output);
|
||||
try dol.writeDOL(dolMap, input, output, verbose);
|
||||
}
|
||||
|
|
|
@ -27,5 +27,5 @@ pub fn main() !void {
|
|||
const output = try std.fs.cwd().createFile(outputPath, .{});
|
||||
defer output.close();
|
||||
|
||||
try lib.convert(input, output);
|
||||
try lib.convert(input, output, true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue