summaryrefslogtreecommitdiff
path: root/src/apk_applet.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-05-12 19:42:32 +0300
committerTimo Teräs <timo.teras@iki.fi>2014-05-12 19:45:36 +0300
commit1e36692a8aee88564b19e6855febd91b4feea5eb (patch)
tree660ef9f645c7462ce176a0c45be3844c0e894f26 /src/apk_applet.h
parent73a03c2e40b9c429342729d009801751bd0812da (diff)
downloadapk-tools-1e36692a8aee88564b19e6855febd91b4feea5eb.tar.gz
apk-tools-1e36692a8aee88564b19e6855febd91b4feea5eb.tar.bz2
apk-tools-1e36692a8aee88564b19e6855febd91b4feea5eb.tar.xz
apk-tools-1e36692a8aee88564b19e6855febd91b4feea5eb.zip
finally fix building PIE binaries
the dynamic applet registration never worked with PIE, and as a temporary hack -nopie was added to default link flags in 2008. this commit reworks the applet registration mechanism to something that is compatible with PIE, and removes the hack. finally!
Diffstat (limited to 'src/apk_applet.h')
-rw-r--r--src/apk_applet.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/apk_applet.h b/src/apk_applet.h
index fa690fc..d11c259 100644
--- a/src/apk_applet.h
+++ b/src/apk_applet.h
@@ -25,6 +25,8 @@ struct apk_option {
};
struct apk_applet {
+ struct list_head node;
+
const char *name;
const char *arguments;
const char *help;
@@ -39,10 +41,11 @@ struct apk_applet {
int (*main)(void *ctx, struct apk_database *db, struct apk_string_array *args);
};
-extern struct apk_applet *__start_apkapplets, *__stop_apkapplets;
+void apk_applet_register(struct apk_applet *);
+typedef void (*apk_init_func_t)(void);
#define APK_DEFINE_APPLET(x) \
- static struct apk_applet *__applet_##x \
- __attribute__((__section__("apkapplets"))) __attribute((used)) = &x;
+static void __register_##x(void) { apk_applet_register(&x); } \
+static apk_init_func_t __regfunc_##x __attribute__((__section__("initapplets"))) __attribute((used)) = __register_##x;
#endif