[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH 4/4] build: Unterstuetzung fuer Linkerskripts
+ build: Wenn im Verzeichnis, in dem die Binary gebaut werden soll, eine
*.ld-Datei vorhanden ist, wird sie als Linkerskript benutzt.
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
src/modules/c/build/build.c | 7 ++++++-
src/modules/c/build/dir.c | 7 +++++++
src/modules/c/build/include/build.h | 2 ++
3 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/modules/c/build/build.c b/src/modules/c/build/build.c
index 683428b..4c899c8 100644
--- a/src/modules/c/build/build.c
+++ b/src/modules/c/build/build.c
@@ -257,7 +257,12 @@ static void do_build(struct build_dir* dir, const char* parent_include,
if (!standalone) {
do_command(".", linker, "-o %s/run %s %s", dir->path, lib, objs);
} else {
- do_command(".", linker, "-o %s/run --start-group %s %s --end-group", dir->path, lib, objs);
+ do_command(".", linker, "-o %s/run %s%s "
+ "--start-group %s %s --end-group",
+ dir->path,
+ dir->ldscript ? "-T" : "",
+ dir->ldscript ? dir->ldscript : "",
+ lib, objs);
}
free(objs);
}
diff --git a/src/modules/c/build/dir.c b/src/modules/c/build/dir.c
index 39b3ac6..b77c467 100644
--- a/src/modules/c/build/dir.c
+++ b/src/modules/c/build/dir.c
@@ -109,6 +109,8 @@ struct build_dir* scan_directory(struct build_dir* parent, const char* path)
filetype = OTHER_FILE;
} else if (!strcmp(suffix, ".o")) {
filetype = OBJ;
+ } else if (!strcmp(suffix, ".ld")) {
+ filetype = LD_SCRIPT;
} else if (!strcmp(suffix, ".c")) {
filetype = LANG_C;
} else if (!strcmp(suffix, ".pas")) {
@@ -174,6 +176,11 @@ struct build_dir* scan_directory(struct build_dir* parent, const char* path)
}
}
break;
+ case LD_SCRIPT:
+ // Ein Linkerskript pro Verzeichnis
+ build_dir->ldscript = file->name;
+ free(file);
+ break;
case OBJ:
// Objektdateien haben ihre eigene Liste
list_push(build_dir->obj_files, file);
diff --git a/src/modules/c/build/include/build.h b/src/modules/c/build/include/build.h
index b1d7659..3efced2 100644
--- a/src/modules/c/build/include/build.h
+++ b/src/modules/c/build/include/build.h
@@ -46,6 +46,7 @@ enum filetype {
#define MAX_LANG OTHER_FILE
OTHER_FILE,
+ LD_SCRIPT,
SUBDIR,
OBJ,
};
@@ -58,6 +59,7 @@ struct build_dir {
int has_include;
int has_arch_include;
char* path;
+ char* ldscript;
struct build_dir* parent;
struct build_dir* lib;
list_t* src_files[MAX_LANG];
--
1.5.6.5