[coreboot-gerrit] Patch set updated for coreboot: d3ccd05 CAR_GLOBAL: enforce compiler to check if _start != _end

Edward O'Callaghan (eocallaghan@alterapraxis.com) gerrit at coreboot.org
Wed Feb 19 19:14:48 CET 2014


Edward O'Callaghan (eocallaghan at alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4719

-gerrit

commit d3ccd053444a4008d611f5769732a9288954c082
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date:   Thu Feb 20 05:10:09 2014 +1100

    CAR_GLOBAL: enforce compiler to check if _start != _end
    
    There are some fun rules C compilers can use to optimize their code.
    One of them is the assumption that two symbols point to two different
    addresses.
    In this case this wasn't true, resulting in unintended code execution
    (and later, a crash) with a clang build.
    
    Change-Id: I1496b22e1d1869ed0610e321b6ec6a83252e9d8b
    Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
    Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
 src/arch/x86/init/romstage.ld | 1 +
 src/cpu/x86/car.c             | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/arch/x86/init/romstage.ld b/src/arch/x86/init/romstage.ld
index f44185f..5458cfc 100644
--- a/src/arch/x86/init/romstage.ld
+++ b/src/arch/x86/init/romstage.ld
@@ -37,6 +37,7 @@ SECTIONS
 		. = ALIGN(16);
 		_car_migrate_start = .;
 		*(.car.migrate);
+		LONG(0);
 		_car_migrate_end = .;
 		. = ALIGN(16);
 		_erom = .;
diff --git a/src/cpu/x86/car.c b/src/cpu/x86/car.c
index 481153d..a7e3842 100644
--- a/src/cpu/x86/car.c
+++ b/src/cpu/x86/car.c
@@ -26,7 +26,6 @@
 typedef void (* const car_migration_func_t)(void);
 
 extern car_migration_func_t _car_migrate_start;
-extern car_migration_func_t _car_migrate_end;
 
 extern char _car_data_start[];
 extern char _car_data_end[];
@@ -98,7 +97,7 @@ void car_migrate_variables(void)
 
 	/* Call all the migration functions. */
 	migrate_func = &_car_migrate_start;
-	while (migrate_func != &_car_migrate_end) {
+	while (*migrate_func != NULL) {
 		(*migrate_func)();
 		migrate_func++;
 	}



More information about the coreboot-gerrit mailing list