-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Pad segment and make LinkerEntry a bit more flexible (#319)
* Allow changing the behavior of each emited linker entry by making a subclass of LinkerEntry * a bit more of cleanup * Remove hardcoded `lib` stuff from `linker_entry` * Implement pad segment * black * write docs for `pad` * ld_generate_symbol_per_data_segment * black * version bump
- Loading branch information
1 parent
bf661e7
commit a52a916
Showing
9 changed files
with
148 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from pathlib import Path | ||
from typing import List | ||
|
||
from segtypes.common.segment import CommonSegment | ||
from segtypes.linker_entry import LinkerEntry, LinkerWriter | ||
from segtypes.segment import Segment | ||
|
||
|
||
class LinkerEntryPad(LinkerEntry): | ||
def __init__( | ||
self, | ||
segment: Segment, | ||
): | ||
super().__init__(segment, [], Path(), "pad", "pad", False) | ||
self.object_path = None | ||
|
||
def emit_entry(self, linker_writer: LinkerWriter): | ||
linker_writer._writeln(f". += 0x{self.segment.size:X};") | ||
|
||
|
||
class CommonSegPad(CommonSegment): | ||
def get_linker_entries(self) -> List[LinkerEntry]: | ||
return [LinkerEntryPad(self)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
from pathlib import Path | ||
from typing import List | ||
|
||
from segtypes.n64.segment import N64Segment | ||
from segtypes.linker_entry import LinkerEntry, LinkerWriter | ||
from segtypes.segment import Segment | ||
|
||
|
||
class LinkerEntryOffset(LinkerEntry): | ||
def __init__( | ||
self, | ||
segment: Segment, | ||
): | ||
super().__init__(segment, [], Path(), "linker_offset", "linker_offset", False) | ||
self.object_path = None | ||
|
||
def emit_entry(self, linker_writer: LinkerWriter): | ||
linker_writer._write_symbol(f"{self.segment.get_cname()}_OFFSET", ".") | ||
|
||
|
||
class N64SegLinker_offset(N64Segment): | ||
def get_linker_entries(self): | ||
from segtypes.linker_entry import LinkerEntry | ||
|
||
return [ | ||
LinkerEntry( | ||
self, [], Path(self.name), "linker_offset", "linker_offset", False | ||
) | ||
] | ||
def get_linker_entries(self) -> List[LinkerEntry]: | ||
return [LinkerEntryOffset(self)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters