Skip to content

feat: add __executable_start#1257

Closed
mati865 wants to merge 3 commits into
wild-linker:mainfrom
mati865:push-ztskrtklzoun
Closed

feat: add __executable_start#1257
mati865 wants to merge 3 commits into
wild-linker:mainfrom
mati865:push-ztskrtklzoun

Conversation

@mati865

@mati865 mati865 commented Nov 1, 2025

Copy link
Copy Markdown
Member

cc #1096

ty: sht::PROGBITS,
section_flags: shf::ALLOC.with(shf::EXECINSTR),
start_symbol_name: Some(EXECUTABLE_START),
..DEFAULT_DEFS

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong because that symbols should be emitted only for (some kinds of?) executables. Probably should be created inside Prelude::new.

Similarly, Wild outputs __ehdr_start even when other linkers don't, and it also misses __dso_handle symbol.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked into this too much, but a couple of things that you were probably aware of, but just in case... some of these symbols are PROVIDE in the GNU ld linker script, which AFAIK means that the linker script should only define the symbol if it's referenced and not defined by anything input objects. We don't yet support PROVIDE semantics, although it might be being worked on - #1097.

Some flags can affect the built-in linker script that GNU ld uses. You can see what changes for some particular flag with a command like meld <(ld --verbose) <(ld --pie --verbose).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't see your comment when I was writing the other one (GitHub didn't refresh automatically). Well, I was unaware but figured that out eventually.

@mati865

mati865 commented Nov 4, 2025

Copy link
Copy Markdown
Member Author

Quick update:
Ah, I think now I understand how __executable_start and __ehdr_start are supposed to work. Looks like the linker should provide them if they are undefined in the input files, so I'm looking into creating something similar as allocate_start_stop_symbol_id does.

With the latest change, eyra now passes many more tests and example_crate_no_std failure doesn't seem to be related to __executable_start. I'm not sure if merging such stopgap workaround is feasible.

pub(crate) link: &'static [OutputSectionId],
pub(crate) start_symbol_name: Option<&'static str>,
pub(crate) end_symbol_name: Option<&'static str>,
pub(crate) synthetic_symbol_names: Option<&'static [&'static str]>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there intended to be a difference between None and Some(&[]) here? If not, then we could get rid of the Option.

Is this intended to be different to start_symbol_name? i.e. is this supposed to be start-symbols that have provide-semantics? I'm unsure about the naming, since these symbols seem just as synthetic as the start/end symbols. I guess until such time as we support provide-semantics, one option would be to change start_symbol_name: Option<&'static str>tostart_symbol_names: &'static [&'static str]. Then, once we support provide-semantics, split it out into two separate fields. e.g. start_symbol_namesandprovide_start_symbol_names` or something like that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was just a proof of concept because I'm not sure whether it's worth doing it.

The only difference from start symbols is the fact they shouldn't be provided by default, but it's not fulfilled yet.

The naming is based on LLD. I tried to find any docs regarding what those symbols are and LLD comments are probably the best (at least they exist). There I noticed they are referred as synthetic symbols. I'm not happy with that name though.

The next release is probably far away, so we can wait for provide. I don't think this is something of high priority.

@mati865

mati865 commented Nov 16, 2025

Copy link
Copy Markdown
Member Author

Let's wait until we can do it in a more reasonable way.

@mati865 mati865 closed this Nov 16, 2025
@mati865 mati865 deleted the push-ztskrtklzoun branch November 16, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants