Skip to content

Commit 09d3791

Browse files
committed
fix ldscript emission
1 parent 9ab9ea0 commit 09d3791

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/AMDAIETargetLdScript.cpp

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,15 @@ static void writeLDScriptMap(raw_ostream &output, BufferOp buf, int offset) {
2323
output << ". += 0x" << llvm::utohexstr(numBytes) << ";\n";
2424
}
2525

26-
///// ld.script format:
27-
//
28-
// MEMORY
29-
// {
30-
// program (RX) : ORIGIN = 0, LENGTH = 0x0020000
31-
// data (!RX) : ORIGIN = 0x20000, LENGTH = 0x0020000
32-
// }
33-
// ENTRY(_main_init)
34-
// INPUT(something.o)
35-
// SECTIONS
36-
// {
37-
// . = 0x0;
38-
// .text : {
39-
// // the __start symbol from crt0.o has to come at address zero.
40-
// *crt0.o(.text)
41-
// . = 0x200;
42-
// *(.text)
43-
// } > program
44-
// .data : { *(.data) } > data
45-
// . = 0x20000;
46-
// _sp_start_value_DM_stack = .;
47-
// . = 0x24000;
48-
// a = .;
49-
// . += 1024;
50-
// .bss : { *(.bss) } > data
51-
// }
5226
LogicalResult mlir::iree_compiler::AMDAIE::AIETranslateToLdScript(
5327
DeviceOp deviceOp, raw_ostream &output, int tileCol, int tileRow) {
5428
DenseMap<TileLoc, Operation *> tiles;
5529
DenseMap<Operation *, SmallVector<BufferOp, 4>> buffers;
5630

57-
5831
collectTiles(deviceOp, tiles);
5932
::collectBuffers(deviceOp, buffers);
6033

61-
AMDAIEDeviceModel deviceModel =
62-
getDeviceModel(static_cast<AMDAIEDevice>(deviceOp.getDevice()));
34+
AMDAIEDeviceModel deviceModel = getDeviceModel(deviceOp.getDevice());
6335
for (auto tile : deviceOp.getOps<TileOp>())
6436
if (tile.getCol() == tileCol && tile.getRow() == tileRow) {
6537
TileLoc srcCoord = {tile.getCol(), tile.getRow()};
@@ -95,9 +67,33 @@ SECTIONS
9567
*(.data*);
9668
*(.rodata*)
9769
} > data
70+
.comment : {
71+
*(.comment*)
72+
}
73+
.symtab : {
74+
*(.symtab)
75+
}
76+
.shstrtab : {
77+
*(.shstrtab)
78+
}
79+
.strtab : {
80+
*(.strtab)
81+
}
82+
.tctmemtab : {
83+
*(.tctmemtab)
84+
}
85+
.rtstab : {
86+
*(.rtstab)
87+
}
88+
.eoltab : {
89+
*(.eoltab)
90+
}
91+
.chesstypeannotationtab : {
92+
*(.chesstypeannotationtab)
93+
}
9894
)THESCRIPT";
9995
auto doBuffer = [&](std::optional<TileLoc> tile, int offset,
100-
const std::string& dir) {
96+
const std::string &dir) {
10197
if (tile) {
10298
if (tiles.count({tile->col, tile->row}))
10399
for (auto buf : buffers[tiles[{tile->col, tile->row}]])
@@ -132,7 +128,6 @@ SECTIONS
132128
deviceModel.getMemEastBaseAddress(), std::string("east"));
133129

134130
output << " .bss : { *(.bss) } > data\n";
135-
output << " .bss.DMb.4 : { *(.bss.DMb.4) } > data\n";
136131
output << "}\n";
137132
if (auto coreOp = getCoreOp(tile)) {
138133
output << "PROVIDE(main = core_" << std::to_string(tile.getCol()) << "_"

compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ static LogicalResult generateCoreElfFiles(
614614
}
615615
flags.emplace_back("--target=" + targetLower + "-none-unknown-elf");
616616
flags.emplace_back("-Wl,--gc-sections");
617+
flags.emplace_back("-Wl,--orphan-handling=error");
617618
flags.emplace_back("-Wl,-T," + ldscriptPath.string());
618619
flags.emplace_back("-o");
619620
flags.emplace_back(elfFile.string());

0 commit comments

Comments
 (0)