summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2019-11-29 17:01:37 -0700
committerGitHub <noreply@github.com>2019-11-29 17:01:37 -0700
commite838d001437ef9ec30ba285644533845dbec17fc (patch)
tree0dd84347f7041d9707bc0e38dc1b5ae7538781a7
parentcd15d119ffb7cc9610290ea6fe2f154ded677dc1 (diff)
downloadbcm5719-ortega-e838d001437ef9ec30ba285644533845dbec17fc.tar.gz
bcm5719-ortega-e838d001437ef9ec30ba285644533845dbec17fc.zip
elf2ape: Embed the target name in the ape header. (#7)
-rw-r--r--cmake/arm.cmake2
-rw-r--r--utils/elf2ape/main.cpp12
2 files changed, 13 insertions, 1 deletions
diff --git a/cmake/arm.cmake b/cmake/arm.cmake
index 7236927..5f4f3de 100644
--- a/cmake/arm.cmake
+++ b/cmake/arm.cmake
@@ -65,7 +65,7 @@ function(arm_add_executable target)
add_custom_command(
TARGET ${target} POST_BUILD
- COMMAND elf2ape -i ${target} -o ${target}.bin
+ COMMAND elf2ape -n ${target} -i ${target} -o ${target}.bin
BYPRODUCTS ${target}.bin
DEPENDS elf2ape)
diff --git a/utils/elf2ape/main.cpp b/utils/elf2ape/main.cpp
index 0f6d54d..6386437 100644
--- a/utils/elf2ape/main.cpp
+++ b/utils/elf2ape/main.cpp
@@ -139,6 +139,12 @@ int main(int argc, char const *argv[])
.help("Output ape binary")
.metavar("FILE");
+ parser.add_option("-n", "--name")
+ .dest("name")
+ .help("Output ape binary")
+ .metavar("FILE");
+
+
optparse::Values options = parser.parse_args(argc, argv);
vector<string> args = parser.args();
@@ -263,6 +269,12 @@ int main(int argc, char const *argv[])
ape.header.magic = APE_HEADER_MAGIC;
ape.header.unk0 = APE_HEADER_UNK0;
// ape.header.name =
+ if (options.is_set("name"))
+ {
+ string name = options["name"];
+ strncpy((char*)ape.header.name, name.c_str(), sizeof(ape.header.name));
+ }
+
ape.header.version = get_symbol_value("VERSION", reader);
ape.header.entrypoint = get_symbol_value("__start", reader);
ape.header.unk1 = APE_HEADER_UNK1;
OpenPOWER on IntegriCloud