Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

.init_array support and opt-in heap allocator #11

Closed
wants to merge 2 commits into from
Closed

Conversation

japaric
Copy link
Contributor

@japaric japaric commented Feb 20, 2017

With .init_array support, external crates (dependencies) can run code before
main is executed.

Usage looks like this:

extern crate alloc_cortex_m;
#[macro_use]  // for `init_array!`
extern crate r0;

init_array!(alloc, {
    alloc_cortex_m::init(..);
});

However, the implementation is not reliable because there's no mechanism to
force rustc to emit symbols when they are apparently not used. Something like
GCC's __attribute(used)__ would fix this. See rust-lang/rfcs#1002 and
rust-lang/rfcs#1459 for previous request of this feature.

Jorge Aparicio added 2 commits February 19, 2017 21:28
Both sections are array of function pointers that get executed before main.
.pre_init_array gets executed before .init_array
via the "alloc" Cargo feature
@toothbrush7777777
Copy link

IIRC, specifying the item as pub will keep the symbol whether used or not.

@japaric
Copy link
Contributor Author

japaric commented Apr 7, 2017

@toothbrush7777777 Yes, but with that approach the symbols end up being part of your public API.

@japaric
Copy link
Contributor Author

japaric commented May 5, 2017

This template has been deprecated in favor of the cortex-m-quickstart template.

@japaric japaric closed this May 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants