Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,13 @@ fn linker_with_args(
// Passed after compiler-generated options to support manual overriding when necessary.
add_user_defined_link_args(cmd, sess);

// ------------ Builtin configurable linker scripts ------------
// The user's link args should be able to overwrite symbols in the compiler's
// linker script that were weakly defined (i.e. defined with `PROVIDE()`). For this
// to work correctly, the user needs to be able to specify linker arguments like
// `--defsym` and `--script` *before* any builtin linker scripts are evaluated.
add_link_script(cmd, sess, tmpdir, crate_type);

// ------------ Object code and libraries, order-dependent ------------

// Post-link CRT objects.
Expand Down Expand Up @@ -2469,8 +2476,6 @@ fn add_order_independent_options(

let apple_sdk_root = add_apple_sdk(cmd, sess, flavor);

add_link_script(cmd, sess, tmpdir, crate_type);

if sess.target.os == "fuchsia"
&& crate_type == CrateType::Executable
&& !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ PROVIDE(__vcodesig_type = 0); /* V5_SIG_TYPE_USER */
PROVIDE(__vcodesig_owner = 2); /* V5_SIG_OWNER_PARTNER */
PROVIDE(__vcodesig_options = 0); /* none (0) */

PROVIDE(__user_ram_start = 0x03800000);
PROVIDE(__user_ram_length = 48M);
PROVIDE(__user_ram_end = __user_ram_start + __user_ram_length); /* 0x8000000 */
__user_ram_start = 0x03800000;
__user_ram_end = 0x08000000;
/* (0x48 =) 72 MiB length */
__user_ram_length = __user_ram_start - __user_ram_end;

PROVIDE(__code_signature_length = 0x20);
/*
* VEXos provides a method for pre-loading a "linked file" at a specified
* address in User RAM, conventionally near the end, after the primary
* program binary. We need to be sure not to place any data in that location,
* so we allow the user of this linker script to inform the start address of
* this blob.
*/
PROVIDE(__linked_file_length = 0);
PROVIDE(__linked_file_end = __user_ram_end);
PROVIDE(__linked_file_start = __linked_file_end - __linked_file_length);

PROVIDE(__stack_length = 4M);
PROVIDE(__heap_end = __user_ram_end - __stack_length);
PROVIDE(__user_length = __heap_start - __user_ram_start);
PROVIDE(__stack_top = __linked_file_start);
PROVIDE(__stack_bottom = __linked_file_start - __stack_length);

MEMORY {
USER_RAM (RWX) : ORIGIN = __user_ram_start, LENGTH = __user_ram_length
Expand All @@ -44,7 +54,7 @@ SECTIONS {
LONG(__vcodesig_options)

FILL(0)
. = __user_ram_start + __code_signature_length;
. = __user_ram_start + 0x20;
} > USER_RAM

/*
Expand Down Expand Up @@ -125,7 +135,8 @@ SECTIONS {
*/
.heap (NOLOAD) : {
__heap_start = .;
. = __heap_end;
. = __stack_bottom;
__heap_end = .;
} > USER_RAM

.stack (NOLOAD) : ALIGN(8) {
Expand Down
Loading