Skip to content

Commit 68b4327

Browse files
[devtools] Add option to output linker map files
1 parent 94c5fe0 commit 68b4327

18 files changed

+41
-10
lines changed

libs/rteutils/include/RteConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class RteConstants
9292
static constexpr const char* OUTPUT_TYPE_HEX = "hex";
9393
static constexpr const char* OUTPUT_TYPE_LIB = "lib";
9494
static constexpr const char* OUTPUT_TYPE_CMSE = "cmse-lib";
95+
static constexpr const char* OUTPUT_TYPE_MAP = "map";
9596

9697
/**
9798
* @brief access sequences
@@ -119,6 +120,7 @@ class RteConstants
119120
static constexpr const char* AS_HEX = OUTPUT_TYPE_HEX;
120121
static constexpr const char* AS_LIB = OUTPUT_TYPE_LIB;
121122
static constexpr const char* AS_CMSE = OUTPUT_TYPE_CMSE;
123+
static constexpr const char* AS_MAP = OUTPUT_TYPE_MAP;
122124

123125
/**
124126
* @brief default and toolchain specific output affixes

tools/buildmgr/cbuildgen/config/AC6.6.16.2.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@ set (ELF2HEX --i32combined --output "${OUT_DIR}/${HEX_FILE}" "${OUT_DIR}/$<TARGE
731731
# ELF to BIN conversion
732732
set (ELF2BIN --bin --output "${OUT_DIR}/${BIN_FILE}" "${OUT_DIR}/$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>$<TARGET_PROPERTY:${TARGET},SUFFIX>")
733733

734+
# Linker Map file generation
735+
set (LD_MAP --map --info summarysizes --summary_stderr --list=${OUT_DIR}/${LD_MAP_FILE})
736+
734737
# Set CMake variables for toolchain initialization
735738
set(CMAKE_C_FLAGS_INIT "${CC_CPU}")
736739
set(CMAKE_CXX_FLAGS_INIT "${CXX_CPU}")

tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ set (ELF2HEX -O ihex "${OUT_DIR}/$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>$<TARGE
434434
# ELF to BIN conversion
435435
set (ELF2BIN -O binary "${OUT_DIR}/$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>$<TARGET_PROPERTY:${TARGET},SUFFIX>" "${OUT_DIR}/${BIN_FILE}")
436436

437+
# Linker Map file generation
438+
set (LD_MAP -Wl,-Map=${OUT_DIR}/${LD_MAP_FILE})
439+
437440
# Set CMake variables for toolchain initialization
438441
set(CMAKE_C_FLAGS_INIT "${CC_CPU}")
439442
set(CMAKE_CXX_FLAGS_INIT "${CXX_CPU}")

tools/buildmgr/cbuildgen/config/GCC.10.3.1.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ set (ELF2HEX -O ihex "${OUT_DIR}/$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>$<TARGE
317317
# ELF to BIN conversion
318318
set (ELF2BIN -O binary "${OUT_DIR}/$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>$<TARGET_PROPERTY:${TARGET},SUFFIX>" "${OUT_DIR}/${BIN_FILE}")
319319

320+
# Linker Map file generation
321+
set (LD_MAP -Wl,-Map=${OUT_DIR}/${LD_MAP_FILE})
322+
320323
# Set CMake variables for toolchain initialization
321324
set(CMAKE_C_FLAGS_INIT "${CC_CPU}")
322325
set(CMAKE_CXX_FLAGS_INIT "${CXX_CPU}")

tools/buildmgr/cbuildgen/config/IAR.9.32.1.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ set (ELF2HEX --silent --ihex "${OUT_DIR}/$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME
326326
# ELF to BIN conversion
327327
set (ELF2BIN --silent --bin "${OUT_DIR}/$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>$<TARGET_PROPERTY:${TARGET},SUFFIX>" "${OUT_DIR}/${BIN_FILE}")
328328

329+
# Linker Map file generation
330+
set (LD_MAP --map=${OUT_DIR}/${LD_MAP_FILE})
331+
329332
# Set CMake variables for toolchain initialization
330333
set(CMAKE_SYSTEM_NAME Generic)
331334
set(CMAKE_CROSSCOMPILING TRUE)

tools/projmgr/include/ProjMgrUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ struct OutputType {
5858
* hex output type
5959
* lib output type
6060
* cmse output type
61+
* map output type
6162
*/
6263
struct OutputTypes {
6364
OutputType bin;
6465
OutputType elf;
6566
OutputType hex;
6667
OutputType lib;
6768
OutputType cmse;
69+
OutputType map;
6870
};
6971

7072
/**

tools/projmgr/schemas/common.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@
199199
"items": { "$ref": "#/definitions/ArtifactType" }
200200
},
201201
"ArtifactType": {
202-
"enum": [ "elf", "hex", "bin", "lib", "cmse-lib" ],
203-
"description": "Output type: elf (default), hex, bin, lib or cmse-lib"
202+
"enum": [ "elf", "hex", "bin", "lib", "cmse-lib", "map" ],
203+
"description": "Output type: elf (default), hex, bin, lib, cmse-lib or map"
204204
},
205205
"ArtifactsType": {
206206
"oneOf": [

tools/projmgr/src/ProjMgrUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ void ProjMgrUtils::SetOutputType(const string typeString, OutputTypes& type) {
162162
type.lib.on = true;
163163
} else if (typeString == RteConstants::OUTPUT_TYPE_CMSE) {
164164
type.cmse.on = true;
165+
} else if (typeString == RteConstants::OUTPUT_TYPE_MAP) {
166+
type.map.on = true;
165167
}
166168
}
167169

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static const regex accessSequencesRegEx = regex(string("^(") +
2525
RteConstants::AS_ELF + "|" +
2626
RteConstants::AS_HEX + "|" +
2727
RteConstants::AS_LIB + "|" +
28+
RteConstants::AS_MAP + "|" +
2829
RteConstants::AS_CMSE + ")" +
2930
"\\((.*)\\)$"
3031
);
@@ -2397,6 +2398,7 @@ void ProjMgrWorker::SetBuildOutputDependencies(const OutputTypes& types, const s
23972398
{ types.hex.on, types.hex.filename },
23982399
{ types.lib.on, types.lib.filename },
23992400
{ types.cmse.on, types.cmse.filename },
2401+
{ types.map.on, types.map.filename },
24002402
};
24012403
for (auto [on, file] : outputTypes) {
24022404
if (on) {
@@ -3224,6 +3226,9 @@ void ProjMgrWorker::ExpandAccessSequence(const ContextItem& context, const Conte
32243226
} else if (sequence == RteConstants::AS_CMSE) {
32253227
regExStr += RteConstants::AS_CMSE;
32263228
replacement = refContext.outputTypes.cmse.on ? relOutDir + "/" + refContext.outputTypes.cmse.filename : "";
3229+
} else if (sequence == RteConstants::AS_MAP) {
3230+
regExStr += RteConstants::AS_MAP;
3231+
replacement = refContext.outputTypes.map.on ? relOutDir + "/" + refContext.outputTypes.map.filename : "";
32273232
}
32283233
regex regEx = regex(regExStr + "\\(.*\\)\\$");
32293234
item = regex_replace(item, regEx, replacement);
@@ -4711,6 +4716,9 @@ bool ProjMgrWorker::ProcessOutputFilenames(ContextItem& context) {
47114716
if (context.outputTypes.bin.on) {
47124717
context.outputTypes.bin.filename = baseName + ".bin";
47134718
}
4719+
if (context.outputTypes.map.on) {
4720+
context.outputTypes.map.filename = baseName + get<0>(affixesMap.at(toolchain)) + ".map";
4721+
}
47144722
if (context.outputTypes.cmse.on) {
47154723
context.outputTypes.cmse.filename = baseName + "_CMSE_Lib.o";
47164724
}

tools/projmgr/src/ProjMgrYamlEmitter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ void ProjMgrYamlCbuild::SetOutputNode(YAML::Node node, const ContextItem* contex
769769
{ types.hex.on, types.hex.filename, RteConstants::OUTPUT_TYPE_HEX },
770770
{ types.lib.on, types.lib.filename, RteConstants::OUTPUT_TYPE_LIB },
771771
{ types.cmse.on, types.cmse.filename, RteConstants::OUTPUT_TYPE_CMSE },
772+
{ types.map.on, types.map.filename, RteConstants::OUTPUT_TYPE_MAP },
772773
};
773774
for (const auto& [on, file, type] : outputTypes) {
774775
if (on) {

0 commit comments

Comments
 (0)