Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update peano linker script generation #1717

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions lib/Targets/AIETargetLdScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,33 @@ static void writeLDScriptMap(raw_ostream &output, BufferOp buf, int offset) {
// program (RX) : ORIGIN = 0, LENGTH = 0x0020000
// data (!RX) : ORIGIN = 0x20000, LENGTH = 0x0020000
// }
// ENTRY(_main_init)
// ENTRY(__start)
// INPUT(something.o)
// SECTIONS
// {
// . = 0x0;
// .text : {
// // the _main_init symbol from me_basic.o has to come at address zero.
// *me_basic.o(.text)
// . = 0x200;
// // the __start symbol has to come at address zero.
// *crt0.o(.text*)
// __ctors_start__ = .;
// __init_array_start = .;
// KEEP(SORT(*)(.init_array))
// __ctors_end__ = .;
// __init_array_end = .;
// __dtors_start__ = .;
// __dtors_end__ = .;
// *(.text)
// *(.text*)
// } > program
// .data : { *(.data) } > data
// .data : { *(.data*) } > data
// . = 0x20000;
// _sp_start_value_DM_stack = .;
// . = 0x24000;
// a = .;
// . += 1024;
// .bss : { *(.bss) } > data
// .bss : { *(.bss*) } > data
// }
// PROVIDE(main = core_3_3);

LogicalResult xilinx::AIE::AIETranslateToLdScript(ModuleOp module,
raw_ostream &output,
int tileCol, int tileRow) {
Expand Down Expand Up @@ -98,27 +99,39 @@ MEMORY
<< ", LENGTH = 0x" << llvm::utohexstr(length);
output << R"THESCRIPT(
}
ENTRY(_main_init)
ENTRY(__start)
SECTIONS
{
. = 0x0;
.text : {
/* the _main_init symbol has to come at address zero. */
*crt0.o(.text)
. = 0x200;
/* the __start symbol has to come at address zero. */
*crt0.o(.text*)
_ctors_start = .;
_init_array_start = .;
KEEP(SORT(*.init_array))
_ctors_end = .;
_init_array_end = .;
_dtors_start = .;
_dtors_end = .;
*(.text)
*(.text*)
} > program
.data : {
*(.data*);
*(.data*)
*(.rodata*)
} > data
.comment : {
*(.comment*)
}
.symtab : {
*(.symtab)
}
.shstrtab : {
*(.shstrtab)
}
.strtab : {
*(.strtab)
}

)THESCRIPT";
auto doBuffer = [&](std::optional<TileID> tile, int offset,
std::string dir) {
Expand Down Expand Up @@ -155,8 +168,7 @@ SECTIONS
doBuffer(targetModel.getMemEast(srcCoord),
targetModel.getMemEastBaseAddress(), std::string("east"));

output << " .bss : { *(.bss) } > data\n";
output << " .bss.DMb.4 : { *(.bss.DMb.4) } > data\n";
output << " .bss : { *(.bss*) } > data\n";
output << "}\n";
if (auto coreOp = tile.getCoreOp()) {
if (auto fileAttr = coreOp.getLinkWith())
Expand Down
5 changes: 4 additions & 1 deletion python/compiler/aiecc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ async def process_core(
install_path, "aie_runtime_lib", aie_target.upper()
)

clang_link_args = ["-Wl,--gc-sections"]
# --gc-sections to eliminate unneeded code.
# --orphan-handling=error to ensure that the linker script is as expected.
# If there are orphaned input sections, then they'd likely end up outside of the normal program memory.
clang_link_args = ["-Wl,--gc-sections", "--orphan-handling=error"]
stephenneuendorffer marked this conversation as resolved.
Show resolved Hide resolved

if opts.progress:
task = self.progress_bar.add_task(
Expand Down
Loading