summaryrefslogtreecommitdiff
path: root/src/basic/static-destruct.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-12-03 13:22:15 +0100
committerLennart Poettering <lennart@poettering.net>2018-12-03 13:28:26 +0100
commita898603563ffb21af5cf8dc91f9a516a41743991 (patch)
tree7c6fe76923f58283b598d95b722b8ef9afcf5ff7 /src/basic/static-destruct.h
parent90b365cee03bab9b4925f2e918c362c4183f8e92 (diff)
downloadsystemd-a898603563ffb21af5cf8dc91f9a516a41743991.tar.gz
sd-bus,static-destruct: clean up how we do our ELF section magic
This cleans up a bit how we set up things for the ELF section magic: 1. Let's always use our gcc macros, instead of __attribute__ directly 2. Align our structures to sizeof(void*), i.e. the pointer size, rather than a fixed 8 or __BIGGEST_ALIGNMENT__. The former is unnecessarily high for 32bit systems, the latter too high for 64bit systems. gcc seems to use ptr alignment for static variables itself, hence this should be good enough for us too. Moreover, the Linux kernel also uses pointer alginment for all its ELF section registration magic, hence this should be good enough for us too. 3. Let's always prefix the sections we create ourself with SYSTEMD_, just to make clear where they come from. 4. Always align the pointer we start from when iterating through these lists. This should be unnecessary, but makes things nicely systematic, as we'll align all pointers we use to access these sections properly.
Diffstat (limited to 'src/basic/static-destruct.h')
-rw-r--r--src/basic/static-destruct.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/basic/static-destruct.h b/src/basic/static-destruct.h
index b780985d11..5c0bea31a6 100644
--- a/src/basic/static-destruct.h
+++ b/src/basic/static-destruct.h
@@ -22,9 +22,9 @@ typedef struct StaticDestructor {
func(q); \
} \
/* The actual destructor structure */ \
- __attribute__ ((__section__("SYSTEMD_STATIC_DESTRUCT"))) \
- __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) \
- __attribute__ ((__used__)) \
+ _section_("SYSTEMD_STATIC_DESTRUCT") \
+ _alignptr_ \
+ _used_ \
static const StaticDestructor UNIQ_T(static_destructor_entry, uq) = { \
.data = &(variable), \
.destroy = UNIQ_T(static_destructor_wrapper, uq), \
@@ -43,9 +43,9 @@ static inline void static_destruct(void) {
if (!__start_SYSTEMD_STATIC_DESTRUCT)
return;
- d = ALIGN_TO_PTR(__start_SYSTEMD_STATIC_DESTRUCT, __BIGGEST_ALIGNMENT__);
+ d = ALIGN_TO_PTR(__start_SYSTEMD_STATIC_DESTRUCT, sizeof(void*));
while (d < __stop_SYSTEMD_STATIC_DESTRUCT) {
d->destroy(d->data);
- d = ALIGN_TO_PTR(d + 1, __BIGGEST_ALIGNMENT__);
+ d = ALIGN_TO_PTR(d + 1, sizeof(void*));
}
}