From: Peter Tyser Date: Tue, 19 Aug 2008 09:35:35 -0500 Subject: [U-Boot] Location of jump table in global_data structure Message-ID: <1219156535.1273.269.camel@localhost.localdomain> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello, I've noticed that the jump table pointer (**jt) in the global_data structure is always the last field in the structure. When standalone applications are compiled, they hard code the jump table pointer offset into the global_data structure. When new versions of U-Boot come out which add/remove a field from the global_data structure, old standalone applications will no longer work as the location of the jt pointer has changed. I've noticed this issue when updating U-Boot from 1.3.0 to 1.3.4. As an example from include/asm-avr32/global_data.h: FROM VERSION 1.3.4: typedef struct global_data { bd_t *bd; unsigned long flags; unsigned long baudrate; unsigned long stack_end; /* highest stack address */ unsigned long have_console; /* serial_init() was called */ unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of env struct */ unsigned long env_valid; /* Checksum of env valid? */ unsigned long cpu_hz; /* cpu core clock frequency */ void **jt; /* jump table */ } gd_t; ?FROM FUTURE VERSION 1.3.5: ?typedef struct global_data { bd_t *bd; unsigned long flags; unsigned long baudrate; unsigned long stack_end; /* highest stack address */ unsigned long have_console; /* serial_init() was called */ unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of env struct */ unsigned long env_valid; /* Checksum of env valid? */ unsigned long cpu_hz; /* cpu core clock frequency */ ====> unsigned long fancy_value; /* FANCY NEW VALUE ADDED!! */ void **jt; /* jump table */ } gd_t; Adding fancy_value to global_data would break any standalone applications compiled for 1.3.4 since the app is now using fancy_value as its jump table pointer (where jt used to be). One possible fix would be to move **jt to the 2nd item in global_data to prevent it moving in the future. This would break everyone's current standalone apps however:) eg: ?typedef struct global_data { bd_t *bd; ====> void **jt; /* jump table */ unsigned long flags; unsigned long baudrate; unsigned long stack_end; /* highest stack address */ unsigned long have_console; /* serial_init() was called */ unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of env struct */ unsigned long env_valid; /* Checksum of env valid? */ unsigned long cpu_hz; /* cpu core clock frequency */ } gd_t; Another option would be to mandate that new fields only be added after the **jt field to prevent it from moving, although this would be hard to enforce and seems a bit hokey. Do others view this issue as a problem that should be fixed? If others feel that the jt pointer should be moved to the 2nd item in global_data structure let me know and I can generate a patch. Best, Peter