Skip to content

Commit

Permalink
[linker] align all the special sections on 8 byte boundaries, remove …
Browse files Browse the repository at this point in the history
…x86-64 hack

A bit overkill for 32bit machines, but aligning all the special data structures
on 8 byte boundaries removes any special case for 64bit machines.
  • Loading branch information
travisg committed Oct 27, 2015
1 parent 0e1ce41 commit 114a350
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/app.ld
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SECTIONS {
.apps ALIGN(8) : {
.apps : ALIGN(8) {
__apps_start = .;
KEEP (*(.apps))
__apps_end = .;
}
}
INSERT AFTER .data;
INSERT AFTER .rodata;
2 changes: 1 addition & 1 deletion dev/devices.ld
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SECTIONS {
.devices ALIGN(8) : {
.devices : ALIGN(8) {
__devices = .;
KEEP (*(.devices))
__devices_end = .;
Expand Down
2 changes: 1 addition & 1 deletion dev/drivers.ld
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SECTIONS {
.drivers : {
.drivers : ALIGN(8) {
__drivers = .;
KEEP (*(.drivers))
__drivers_end = .;
Expand Down
6 changes: 1 addition & 5 deletions include/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ struct app_descriptor {
size_t stack_size;
};

#ifdef ARCH_X86_64
#define APP_START(appname) struct app_descriptor _app_##appname __ALIGNED(8) __SECTION(".apps") = { .name = #appname,
#else
#define APP_START(appname) struct app_descriptor _app_##appname __SECTION(".apps") = { .name = #appname,
#endif
#define APP_START(appname) const struct app_descriptor _app_##appname __SECTION(".apps") = { .name = #appname,

#define APP_END };

Expand Down
8 changes: 0 additions & 8 deletions include/lib/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,11 @@ typedef struct _cmd_block {

#define STATIC_COMMAND_START static const cmd _cmd_list[] = {

#ifdef ARCH_X86_64
#define STATIC_COMMAND_END(name) }; const cmd_block _cmd_block_##name __ALIGNED(8) __SECTION(".commands")= { NULL, sizeof(_cmd_list) / sizeof(_cmd_list[0]), _cmd_list }
#else
#define STATIC_COMMAND_END(name) }; const cmd_block _cmd_block_##name __SECTION(".commands")= { NULL, sizeof(_cmd_list) / sizeof(_cmd_list[0]), _cmd_list }
#endif

#define STATIC_COMMAND_START_NAMED(name) static const cmd _cmd_list_##name[] = {

#ifdef ARCH_X86_64
#define STATIC_COMMAND_END_NAMED(name) }; const cmd_block _cmd_block_##name __ALIGNED(8) __SECTION(".commands")= { NULL, sizeof(_cmd_list_##name) / sizeof(_cmd_list_##name[0]), _cmd_list_##name }
#else
#define STATIC_COMMAND_END_NAMED(name) }; const cmd_block _cmd_block_##name __SECTION(".commands")= { NULL, sizeof(_cmd_list_##name) / sizeof(_cmd_list_##name[0]), _cmd_list_##name }
#endif

#define STATIC_COMMAND(command_str, help_str, func) { command_str, help_str, func, CMD_AVAIL_NORMAL },
#define STATIC_COMMAND_MASKED(command_str, help_str, func, availability_mask) { command_str, help_str, func, availability_mask },
Expand Down
10 changes: 0 additions & 10 deletions include/lk/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,13 @@ struct lk_init_struct {
const char *name;
};

#ifdef ARCH_X86_64
#define LK_INIT_HOOK_FLAGS(_name, _hook, _level, _flags) \
const struct lk_init_struct _init_struct_##_name __ALIGNED(8) __SECTION(".lk_init") = { \
.level = _level, \
.flags = _flags, \
.hook = _hook, \
.name = #_name, \
};
#else
#define LK_INIT_HOOK_FLAGS(_name, _hook, _level, _flags) \
const struct lk_init_struct _init_struct_##_name __SECTION(".lk_init") = { \
.level = _level, \
.flags = _flags, \
.hook = _hook, \
.name = #_name, \
};
#endif

#define LK_INIT_HOOK(_name, _hook, _level) \
LK_INIT_HOOK_FLAGS(_name, _hook, _level, LK_INIT_FLAG_PRIMARY_CPU)
Expand Down
2 changes: 1 addition & 1 deletion lib/console/console.ld
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SECTIONS {
.commands ALIGN(8) : {
.commands : ALIGN(8) {
__commands_start = .;
KEEP (*(.commands))
__commands_end = .;
Expand Down
3 changes: 1 addition & 2 deletions top/init.ld
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
SECTIONS {
.init ALIGN(8) : {
. = ALIGN(8);
.lk_init : ALIGN(8) {
__lk_init = .;
KEEP (*(.lk_init))
__lk_init_end = .;
Expand Down

0 comments on commit 114a350

Please sign in to comment.