4
0
Fork
You've already forked libopencm3
3

Fix: forbidden casts and LTO compatability improvements #2

Merged
esden merged 7 commits from fix/forbidden-casts-and-lto into main 2024年01月14日 07:48:38 +01:00

This PR aims to improve our standards conformance and LTO compatability.

ISO C forbids casting function points to or from void * as the size of a function pointer is allowed to be different from the size of a data pointer, the library should never have been doing this and especially as the casts aren't even required, so we eliminate them for all devices BMD compiles for.

It is an error to do pointer arithmetic on a void pointer - sizeof(void) has no standards-set size, and the operation is meaningless. Luckily all instances of this are trivially convertible to using typed pointers.

LTO requires we mark the vector table, reset vector and vector table's section all used/keep so it doesn't eliminate them due to nothing it can see calling into them.

This PR aims to improve our standards conformance and LTO compatability. ISO C forbids casting function points to or from `void *` as the size of a function pointer is allowed to be different from the size of a data pointer, the library should never have been doing this and especially as the casts aren't even required, so we eliminate them for all devices BMD compiles for. It is an error to do pointer arithmetic on a void pointer - `sizeof(void)` has no standards-set size, and the operation is meaningless. Luckily all instances of this are trivially convertible to using typed pointers. LTO requires we mark the vector table, reset vector and vector table's section all used/keep so it doesn't eliminate them due to nothing it can see calling into them.
esden (Migrated from github.com) approved these changes 2024年01月14日 07:47:11 +01:00
esden (Migrated from github.com) left a comment
Copy link

LGTM

LGTM
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
blackmagic-debug/libopencm3!2
Reference in a new issue
blackmagic-debug/libopencm3
No description provided.
Delete branch "fix/forbidden-casts-and-lto"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?