mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
change strategy for refs to linker symbols to get compatible again with old GCC (6.3), tested on GCC 11 too
This commit is contained in:
parent
1d2752715d
commit
a330401769
5 changed files with 29 additions and 27 deletions
|
@ -14,7 +14,7 @@
|
||||||
#include "dbprint.h"
|
#include "dbprint.h"
|
||||||
#include "pm3_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
|
|
||||||
extern char _stack_start[], __bss_end__[];
|
extern uint32_t _stack_start[], __bss_end__[];
|
||||||
|
|
||||||
// BigBuf is the large multi-purpose buffer, typically used to hold A/D samples or traces.
|
// BigBuf is the large multi-purpose buffer, typically used to hold A/D samples or traces.
|
||||||
// Also used to hold various smaller buffers and the Mifare Emulator Memory.
|
// Also used to hold various smaller buffers and the Mifare Emulator Memory.
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
int DBGLEVEL = DBG_ERROR;
|
int DBGLEVEL = DBG_ERROR;
|
||||||
uint8_t g_trigger = 0;
|
uint8_t g_trigger = 0;
|
||||||
bool g_hf_field_active = false;
|
bool g_hf_field_active = false;
|
||||||
extern char _stack_start[], _stack_end[];
|
extern uint32_t _stack_start[], _stack_end[];
|
||||||
struct common_area common_area __attribute__((section(".commonarea")));
|
struct common_area common_area __attribute__((section(".commonarea")));
|
||||||
static int button_status = BUTTON_NO_CLICK;
|
static int button_status = BUTTON_NO_CLICK;
|
||||||
static bool allow_send_wtx = false;
|
static bool allow_send_wtx = false;
|
||||||
|
@ -240,9 +240,9 @@ static uint32_t MeasureAntennaTuningLfData(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_stack_usage(void) {
|
void print_stack_usage(void) {
|
||||||
for (uint32_t *p = (uint32_t *)_stack_start; ; ++p) {
|
for (uint32_t *p = _stack_start; ; ++p) {
|
||||||
if (*p != 0xdeadbeef) {
|
if (*p != 0xdeadbeef) {
|
||||||
Dbprintf(" Max stack usage......... %d / %d bytes", _stack_end - (char *)p, _stack_end - _stack_start);
|
Dbprintf(" Max stack usage......... %d / %d bytes", (uint32_t)_stack_end - (uint32_t)p, (uint32_t)_stack_end - (uint32_t)_stack_start);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,9 +256,9 @@ void ReadMem(int addr) {
|
||||||
|
|
||||||
/* osimage version information is linked in, cf commonutil.h */
|
/* osimage version information is linked in, cf commonutil.h */
|
||||||
/* bootrom version information is pointed to from _bootphase1_version_pointer */
|
/* bootrom version information is pointed to from _bootphase1_version_pointer */
|
||||||
extern char _bootphase1_version_pointer[], _flash_start[], _flash_end[], __data_src_start__[];
|
extern uint32_t _bootphase1_version_pointer[], _flash_start[], _flash_end[], __data_src_start__[];
|
||||||
#ifdef WITH_NO_COMPRESSION
|
#ifdef WITH_NO_COMPRESSION
|
||||||
extern char _bootrom_end[], _bootrom_start[], __os_size__[];
|
extern uint32_t _bootrom_end[], _bootrom_start[], __os_size__[];
|
||||||
#endif
|
#endif
|
||||||
static void SendVersion(void) {
|
static void SendVersion(void) {
|
||||||
char temp[PM3_CMD_DATA_SIZE - 12]; /* Limited data payload in USB packets */
|
char temp[PM3_CMD_DATA_SIZE - 12]; /* Limited data payload in USB packets */
|
||||||
|
@ -268,11 +268,13 @@ static void SendVersion(void) {
|
||||||
* symbol _bootphase1_version_pointer, perform slight sanity checks on the
|
* symbol _bootphase1_version_pointer, perform slight sanity checks on the
|
||||||
* pointer, then use it.
|
* pointer, then use it.
|
||||||
*/
|
*/
|
||||||
char *bootrom_version = *(char **)_bootphase1_version_pointer;
|
// dummy casting to avoid "dereferencing type-punned pointer breaking strict-aliasing rules" errors
|
||||||
|
uint32_t bootrom_version_ptr = (uint32_t)_bootphase1_version_pointer;
|
||||||
|
char *bootrom_version = *(char **)(bootrom_version_ptr);
|
||||||
|
|
||||||
strncat(VersionString, " [ "_YELLOW_("ARM")" ]\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
strncat(VersionString, " [ "_YELLOW_("ARM")" ]\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||||
|
|
||||||
if (bootrom_version < _flash_start || bootrom_version >= _flash_end) {
|
if ((uint32_t)bootrom_version < (uint32_t)_flash_start || (uint32_t)bootrom_version >= (uint32_t)_flash_end) {
|
||||||
strcat(VersionString, "bootrom version information appears invalid\n");
|
strcat(VersionString, "bootrom version information appears invalid\n");
|
||||||
} else {
|
} else {
|
||||||
FormatVersionInformation(temp, sizeof(temp), " bootrom: ", bootrom_version);
|
FormatVersionInformation(temp, sizeof(temp), " bootrom: ", bootrom_version);
|
||||||
|
@ -300,7 +302,7 @@ static void SendVersion(void) {
|
||||||
}
|
}
|
||||||
#ifndef WITH_NO_COMPRESSION
|
#ifndef WITH_NO_COMPRESSION
|
||||||
// Send Chip ID and used flash memory
|
// Send Chip ID and used flash memory
|
||||||
uint32_t text_and_rodata_section_size = __data_src_start__ - _flash_start;
|
uint32_t text_and_rodata_section_size = (uint32_t)__data_src_start__ - (uint32_t)_flash_start;
|
||||||
uint32_t compressed_data_section_size = common_area.arg1;
|
uint32_t compressed_data_section_size = common_area.arg1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -314,7 +316,7 @@ static void SendVersion(void) {
|
||||||
struct p payload;
|
struct p payload;
|
||||||
payload.id = *(AT91C_DBGU_CIDR);
|
payload.id = *(AT91C_DBGU_CIDR);
|
||||||
#ifdef WITH_NO_COMPRESSION
|
#ifdef WITH_NO_COMPRESSION
|
||||||
payload.section_size = _bootrom_end - _bootrom_start + (uint32_t)__os_size__;
|
payload.section_size = (uint32_t)_bootrom_end - (uint32_t)_bootrom_start + (uint32_t)__os_size__;
|
||||||
#else
|
#else
|
||||||
payload.section_size = text_and_rodata_section_size + compressed_data_section_size;
|
payload.section_size = text_and_rodata_section_size + compressed_data_section_size;
|
||||||
#endif
|
#endif
|
||||||
|
@ -2439,7 +2441,7 @@ void __attribute__((noreturn)) AppMain(void) {
|
||||||
SpinDelay(100);
|
SpinDelay(100);
|
||||||
BigBuf_initialize();
|
BigBuf_initialize();
|
||||||
|
|
||||||
for (uint32_t *p = (uint32_t *)_stack_start; p < (uint32_t *)_stack_end - 0x200; ++p) {
|
for (uint32_t *p = _stack_start; p < _stack_end - 0x200; ++p) {
|
||||||
*p = 0xdeadbeef;
|
*p = 0xdeadbeef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2500,8 +2502,8 @@ void __attribute__((noreturn)) AppMain(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
if (*((uint32_t *)_stack_start) != 0xdeadbeef) {
|
if (*_stack_start != 0xdeadbeef) {
|
||||||
Dbprintf("Stack overflow detected! Please increase stack size, currently %d bytes", _stack_end - _stack_start);
|
Dbprintf("Stack overflow detected! Please increase stack size, currently %d bytes", (uint32_t)_stack_end - (uint32_t)_stack_start);
|
||||||
Dbprintf("Unplug your device now.");
|
Dbprintf("Unplug your device now.");
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ typedef lz4_stream *lz4_streamp;
|
||||||
static int downloaded_bitstream = 0;
|
static int downloaded_bitstream = 0;
|
||||||
|
|
||||||
// this is where the bitstreams are located in memory:
|
// this is where the bitstreams are located in memory:
|
||||||
extern char _binary_obj_fpga_all_bit_z_start[], _binary_obj_fpga_all_bit_z_end[];
|
extern uint32_t _binary_obj_fpga_all_bit_z_start[], _binary_obj_fpga_all_bit_z_end[];
|
||||||
|
|
||||||
static uint8_t *fpga_image_ptr = NULL;
|
static uint8_t *fpga_image_ptr = NULL;
|
||||||
static uint32_t uncompressed_bytes_cnt;
|
static uint32_t uncompressed_bytes_cnt;
|
||||||
|
@ -235,8 +235,8 @@ static bool reset_fpga_stream(int bitstream_version, lz4_streamp compressed_fpga
|
||||||
uncompressed_bytes_cnt = 0;
|
uncompressed_bytes_cnt = 0;
|
||||||
|
|
||||||
// initialize z_stream structure for inflate:
|
// initialize z_stream structure for inflate:
|
||||||
compressed_fpga_stream->next_in = _binary_obj_fpga_all_bit_z_start;
|
compressed_fpga_stream->next_in = (char *)_binary_obj_fpga_all_bit_z_start;
|
||||||
compressed_fpga_stream->avail_in = _binary_obj_fpga_all_bit_z_end - _binary_obj_fpga_all_bit_z_start;
|
compressed_fpga_stream->avail_in = (uint32_t)_binary_obj_fpga_all_bit_z_end - (uint32_t)_binary_obj_fpga_all_bit_z_start;
|
||||||
|
|
||||||
int res = LZ4_setStreamDecode(compressed_fpga_stream->lz4StreamDecode, NULL, 0);
|
int res = LZ4_setStreamDecode(compressed_fpga_stream->lz4StreamDecode, NULL, 0);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
|
|
|
@ -21,16 +21,16 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
extern struct common_area common_area;
|
extern struct common_area common_area;
|
||||||
extern char __data_src_start__[], __data_start__[], __data_end__[], __bss_start__[], __bss_end__[];
|
extern uint32_t __data_src_start__[], __data_start__[], __data_end__[], __bss_start__[], __bss_end__[];
|
||||||
|
|
||||||
#ifndef WITH_NO_COMPRESSION
|
#ifndef WITH_NO_COMPRESSION
|
||||||
static void uncompress_data_section(void) {
|
static void uncompress_data_section(void) {
|
||||||
int avail_in;
|
int avail_in;
|
||||||
memcpy(&avail_in, __data_src_start__, sizeof(int));
|
memcpy(&avail_in, __data_src_start__, sizeof(int));
|
||||||
int avail_out = __data_end__ - __data_start__; // uncompressed size. Correct.
|
int avail_out = (uint32_t)__data_end__ - (uint32_t)__data_start__; // uncompressed size. Correct.
|
||||||
// uncompress data segment to RAM
|
// uncompress data segment to RAM
|
||||||
char *p = __data_src_start__;
|
char *p = (char *)__data_src_start__;
|
||||||
int res = LZ4_decompress_safe(p + 4, __data_start__, avail_in, avail_out);
|
int res = LZ4_decompress_safe(p + 4, (char *)__data_start__, avail_in, avail_out);
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return;
|
return;
|
||||||
|
@ -53,15 +53,15 @@ void Vector(void) {
|
||||||
|
|
||||||
/* Set up data segment: Copy from flash to ram */
|
/* Set up data segment: Copy from flash to ram */
|
||||||
#ifdef WITH_NO_COMPRESSION
|
#ifdef WITH_NO_COMPRESSION
|
||||||
char *data_src = __data_src_start__;
|
uint32_t *data_src = __data_src_start__;
|
||||||
char *data_dst = __data_start__;
|
uint32_t *data_dst = __data_start__;
|
||||||
while (data_dst < __data_end__) *data_dst++ = *data_src++;
|
while (data_dst < __data_end__) *data_dst++ = *data_src++;
|
||||||
#else
|
#else
|
||||||
uncompress_data_section();
|
uncompress_data_section();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set up (that is: clear) BSS. */
|
/* Set up (that is: clear) BSS. */
|
||||||
char *bss_dst = __bss_start__;
|
uint32_t *bss_dst = __bss_start__;
|
||||||
while (bss_dst < __bss_end__) *bss_dst++ = 0;
|
while (bss_dst < __bss_end__) *bss_dst++ = 0;
|
||||||
|
|
||||||
AppMain();
|
AppMain();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
struct common_area common_area __attribute__((section(".commonarea")));
|
struct common_area common_area __attribute__((section(".commonarea")));
|
||||||
uint32_t start_addr, end_addr;
|
uint32_t start_addr, end_addr;
|
||||||
bool bootrom_unlocked;
|
bool bootrom_unlocked;
|
||||||
extern char _bootrom_start[], _bootrom_end[], _flash_start[], _flash_end[], _osimage_entry[];
|
extern uint32_t _bootrom_start[], _bootrom_end[], _flash_start[], _flash_end[], _osimage_entry[];
|
||||||
|
|
||||||
static int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
static int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
||||||
PacketResponseOLD txcmd;
|
PacketResponseOLD txcmd;
|
||||||
|
@ -116,7 +116,7 @@ static void UsbPacketReceived(uint8_t *packet) {
|
||||||
uint32_t flash_address = arg0 + (0x100 * j);
|
uint32_t flash_address = arg0 + (0x100 * j);
|
||||||
AT91PS_EFC efc_bank = AT91C_BASE_EFC0;
|
AT91PS_EFC efc_bank = AT91C_BASE_EFC0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
uint32_t page_n = (flash_address - ((uint32_t)_flash_start)) / AT91C_IFLASH_PAGE_SIZE;
|
uint32_t page_n = (flash_address - (uint32_t)_flash_start) / AT91C_IFLASH_PAGE_SIZE;
|
||||||
if (page_n >= AT91C_IFLASH_NB_OF_PAGES / 2) {
|
if (page_n >= AT91C_IFLASH_NB_OF_PAGES / 2) {
|
||||||
page_n -= AT91C_IFLASH_NB_OF_PAGES / 2;
|
page_n -= AT91C_IFLASH_NB_OF_PAGES / 2;
|
||||||
efc_bank = AT91C_BASE_EFC1;
|
efc_bank = AT91C_BASE_EFC1;
|
||||||
|
@ -124,7 +124,7 @@ static void UsbPacketReceived(uint8_t *packet) {
|
||||||
offset = (AT91C_IFLASH_NB_OF_PAGES / 2) * AT91C_IFLASH_PAGE_SIZE / sizeof(uint32_t);
|
offset = (AT91C_IFLASH_NB_OF_PAGES / 2) * AT91C_IFLASH_PAGE_SIZE / sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
for (int i = 0 + (64 * j); i < 64 + (64 * j); i++) {
|
for (int i = 0 + (64 * j); i < 64 + (64 * j); i++) {
|
||||||
((uint32_t *)_flash_start)[offset + i] = c->d.asDwords[i];
|
_flash_start[offset + i] = c->d.asDwords[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that the address that we are supposed to write to is within our allowed region */
|
/* Check that the address that we are supposed to write to is within our allowed region */
|
||||||
|
@ -319,7 +319,7 @@ void BootROM(void) {
|
||||||
|
|
||||||
if ((common_area.command == COMMON_AREA_COMMAND_ENTER_FLASH_MODE) ||
|
if ((common_area.command == COMMON_AREA_COMMAND_ENTER_FLASH_MODE) ||
|
||||||
(!common_area.flags.button_pressed && BUTTON_PRESS()) ||
|
(!common_area.flags.button_pressed && BUTTON_PRESS()) ||
|
||||||
(*(uint32_t *)_osimage_entry == 0xffffffffU)) {
|
(*_osimage_entry == 0xffffffffU)) {
|
||||||
flash_mode();
|
flash_mode();
|
||||||
} else {
|
} else {
|
||||||
// clear button status, even if button still pressed
|
// clear button status, even if button still pressed
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue