Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

gps_time_t struct can cause alignment problems on ARMv6/ARMv7 #4

Closed
njoubert opened this issue Dec 16, 2013 · 1 comment
Closed

gps_time_t struct can cause alignment problems on ARMv6/ARMv7 #4

njoubert opened this issue Dec 16, 2013 · 1 comment

Comments

@njoubert
Copy link
Contributor

In gpstime.h

typedef struct attribute((packed)) {
double tow; /< Seconds since the GPS start of week. */
u16 wn; /
< GPS week number. */
} gps_time_t;

ARMv6 and ARMv7 architectures support unaligned loads for everything everything except double-word structures.

This struct, since it is packed, can cause alignment crashes if an array of these are created and loaded, or if it is inserted into another packed struct.

@njoubert
Copy link
Contributor Author

OK, so this appears to be caught by the compiler, that generates two LDR instructions that can be word-unaligned, rather than a LDRD instruction which has to be word-aligned.

To cause a segfault because of an unaligned LDRD, you can use this snippet:

u8 blah[9] = {1,1,1,1,1,1,1,1,1};
printf("blah = %lf", ((double)&blah[1]));

imh added a commit that referenced this issue Oct 31, 2015
added functions to turn gpstime into python timestamp
valeri-atamaniouk pushed a commit to valeri-atamaniouk/libswiftnav that referenced this issue May 3, 2016
swiftnav: updated python bindings for swiftnav component
ljbade pushed a commit that referenced this issue May 25, 2016
Add calc_sat_state error code handling
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant