Skip to content

Commit c0954dd

Browse files
authored
Merge pull request #4 from Neotron-Compute/support-elf-loader
Support loading ELF binaries.
2 parents 4d8daf9 + a2f2248 commit c0954dd

File tree

5 files changed

+13
-38
lines changed

5 files changed

+13
-38
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ Cargo.lock
1010
**/*.rs.bk
1111

1212

13-
# Added by cargo
13+
samples/*.elf
1414

15-
/target
16-
/Cargo.lock

samples/.cargo/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[target.thumbv7em-none-eabihf]
2-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"]
2+
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"] # , "-C", "link-arg=--nmagic"]
33

44
[target.thumbv7em-none-eabi]
5-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"]
5+
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"] # , "-C", "link-arg=--nmagic"]
66

77
[target.thumbv7m-none-eabi]
8-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"]
8+
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"] # , "-C", "link-arg=--nmagic"]
99

1010
[target.thumbv6m-none-eabi]
11-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"]
11+
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"] # , "-C", "link-arg=--nmagic"]

samples/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ TARGET=${1:-thumbv6m-none-eabi}
77
echo "Building for ${TARGET}"
88
for program in panic hello fault; do
99
( cd ${program} && cargo build --target=${TARGET} --release )
10-
rust-objcopy -O binary ./${program}/target/${TARGET}/release/${program} ${program}.bin
10+
cp ./${program}/target/${TARGET}/release/${program} ${program}.elf
1111
done

samples/neotron-cortex-m.ld

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,28 @@ ENTRY(app_entry);
2525
/* # Sections */
2626
SECTIONS
2727
{
28-
29-
/* ### .entry_point */
30-
.entry_point ORIGIN(RAM) :
31-
{
32-
KEEP(*(.entry_point))
33-
} > RAM
34-
35-
PROVIDE(_stext = ADDR(.entry_point) + SIZEOF(.entry_point));
36-
3728
/* ### .text */
38-
.text _stext :
29+
.text : ALIGN(4)
3930
{
31+
. = ALIGN(4);
4032
*(.text .text.*);
41-
*(.HardFaultTrampoline);
42-
*(.HardFault.*);
33+
. = ALIGN(4);
4334
}
4435

4536
/* ### .rodata */
4637
.rodata : ALIGN(4)
4738
{
39+
. = ALIGN(4);
4840
*(.rodata .rodata.*);
49-
50-
/* 4-byte align the end (VMA) of this section.
51-
This is required by LLD to ensure the LMA of the following .data
52-
section will have the correct alignment. */
5341
. = ALIGN(4);
5442
}
5543

5644
/* ### .data */
5745
.data : ALIGN(4)
5846
{
5947
. = ALIGN(4);
60-
__sdata = .;
6148
*(.data .data.*);
62-
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
63-
__edata = .;
49+
. = ALIGN(4);
6450
}
6551

6652
/* LMA of .data */
@@ -70,10 +56,8 @@ SECTIONS
7056
.bss : ALIGN(4)
7157
{
7258
. = ALIGN(4);
73-
__sbss = .;
7459
*(.bss .bss.*);
75-
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
76-
__ebss = .;
60+
. = ALIGN(4);
7761
}
7862

7963
/* ### .uninit */
@@ -84,10 +68,6 @@ SECTIONS
8468
. = ALIGN(4);
8569
}
8670

87-
/* Place the heap right after `.uninit` */
88-
. = ALIGN(4);
89-
__sheap = .;
90-
9171
/* ## .got */
9272
/* Dynamic relocations are unsupported. This section is only used to detect relocatable code in
9373
the input files and raise an error if relocatable code is found */

src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ extern "C" {
3636
// Static Variables
3737
// ============================================================================
3838

39-
#[link_section = ".entry_point"]
40-
#[used]
41-
pub static APP_ENTRY: AppStartFn = app_entry;
42-
4339
/// Holds a pointer to the OS API provided by the OS on start-up.
4440
///
4541
/// Once you've hit the application `main()`, this will be non-null.
@@ -257,6 +253,7 @@ impl Drop for ReadDir {
257253
///
258254
/// Will jump to the application entry point, and `extern "C"` function
259255
/// called `main`.
256+
#[no_mangle]
260257
extern "C" fn app_entry(api: *mut Api) -> i32 {
261258
API.store(api, Ordering::Relaxed);
262259
unsafe { neotron_main() }

0 commit comments

Comments
 (0)