mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
Merge remote-tracking branch 'origin/amedee/OP-921' into next
This commit is contained in:
commit
fa8c2f239c
@ -34,6 +34,10 @@
|
|||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
#include "pios_struct_helper.h"
|
#include "pios_struct_helper.h"
|
||||||
|
|
||||||
|
#if (defined(__MACH__) && defined(__APPLE__))
|
||||||
|
#include <mach-o/getsect.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|
||||||
// Private types
|
// Private types
|
||||||
@ -41,9 +45,21 @@
|
|||||||
// Macros
|
// Macros
|
||||||
#define SET_BITS(var, shift, value, mask) var = (var & ~(mask << shift)) | (value << shift);
|
#define SET_BITS(var, shift, value, mask) var = (var & ~(mask << shift)) | (value << shift);
|
||||||
|
|
||||||
/* Table of UAVO handles registered at compile time */
|
// Mach-o: dummy segment to calculate ASLR offset in sim_osx
|
||||||
|
#if (defined(__MACH__) && defined(__APPLE__))
|
||||||
|
static long _aslr_offset __attribute__((section("__DATA,_aslr")));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Table of UAVO handles */
|
||||||
|
#if (defined(__MACH__) && defined(__APPLE__))
|
||||||
|
/* Mach-o format */
|
||||||
|
static struct UAVOData ** __start__uavo_handles;
|
||||||
|
static struct UAVOData ** __stop__uavo_handles;
|
||||||
|
#else
|
||||||
|
/* ELF format: automagically defined at compile time */
|
||||||
extern struct UAVOData * __start__uavo_handles[] __attribute__((weak));
|
extern struct UAVOData * __start__uavo_handles[] __attribute__((weak));
|
||||||
extern struct UAVOData * __stop__uavo_handles[] __attribute__((weak));
|
extern struct UAVOData * __stop__uavo_handles[] __attribute__((weak));
|
||||||
|
#endif
|
||||||
|
|
||||||
#define UAVO_LIST_ITERATE(_item) \
|
#define UAVO_LIST_ITERATE(_item) \
|
||||||
for (struct UAVOData ** _uavo_slot = __start__uavo_handles; \
|
for (struct UAVOData ** _uavo_slot = __start__uavo_handles; \
|
||||||
@ -199,6 +215,13 @@ int32_t UAVObjInitialize()
|
|||||||
// Initialize variables
|
// Initialize variables
|
||||||
memset(&stats, 0, sizeof(UAVObjStats));
|
memset(&stats, 0, sizeof(UAVObjStats));
|
||||||
|
|
||||||
|
/* Initialize _uavo_handles start/stop pointers */
|
||||||
|
#if (defined(__MACH__) && defined(__APPLE__))
|
||||||
|
uint64_t aslr_offset = (uint64_t) & _aslr_offset - getsectbyname("__DATA","_aslr")->addr;
|
||||||
|
__start__uavo_handles = (struct UAVOData **) (getsectbyname("__DATA","_uavo_handles")->addr + aslr_offset);
|
||||||
|
__stop__uavo_handles = (struct UAVOData **) ((uint64_t)__start__uavo_handles + getsectbyname("__DATA","_uavo_handles")->size);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialize the uavo handle table
|
// Initialize the uavo handle table
|
||||||
memset(__start__uavo_handles, 0,
|
memset(__start__uavo_handles, 0,
|
||||||
(uintptr_t)__stop__uavo_handles - (uintptr_t)__start__uavo_handles);
|
(uintptr_t)__stop__uavo_handles - (uintptr_t)__start__uavo_handles);
|
||||||
|
@ -40,7 +40,11 @@
|
|||||||
#include "$(NAMELC).h"
|
#include "$(NAMELC).h"
|
||||||
|
|
||||||
// Private variables
|
// Private variables
|
||||||
|
#if (defined(__MACH__) && defined(__APPLE__))
|
||||||
|
static UAVObjHandle handle __attribute__((section("__DATA,_uavo_handles")));
|
||||||
|
#else
|
||||||
static UAVObjHandle handle __attribute__((section("_uavo_handles")));
|
static UAVObjHandle handle __attribute__((section("_uavo_handles")));
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize object.
|
* Initialize object.
|
||||||
|
@ -55,7 +55,11 @@ struct __attribute__((packed)) fw_version_info {
|
|||||||
uint8_t pad[20];
|
uint8_t pad[20];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if (defined(__MACH__) && defined(__APPLE__))
|
||||||
|
const struct fw_version_info fw_version_blob __attribute__((used)) __attribute__((__section__("__TEXT,.fw_version_blob"))) = {
|
||||||
|
#else
|
||||||
const struct fw_version_info fw_version_blob __attribute__((used)) __attribute__((__section__(".fw_version_blob"))) = {
|
const struct fw_version_info fw_version_blob __attribute__((used)) __attribute__((__section__(".fw_version_blob"))) = {
|
||||||
|
#endif
|
||||||
.magic = { 'O','p','F','w' },
|
.magic = { 'O','p','F','w' },
|
||||||
.commit_hash_prefix = 0x${HASH8},
|
.commit_hash_prefix = 0x${HASH8},
|
||||||
.timestamp = ${UNIXTIME},
|
.timestamp = ${UNIXTIME},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user