Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sectcreate Info.plist #60

Open
xd009642 opened this issue Mar 2, 2020 · 6 comments
Open

sectcreate Info.plist #60

xd009642 opened this issue Mar 2, 2020 · 6 comments

Comments

@xd009642
Copy link

xd009642 commented Mar 2, 2020

So I'm trying to do the equivalent of gcc task_for_pid.c -sectcreate __TEXT __info_plist ./Info.plist -o task_for_pid from https://attilathedud.me/mac-os-x-el-capitan-10-11-and-task_for_pid/ and try to use some of the task APIs in rust. But I can't figure out how to link it in because apparently you can't retrospectively append or prepend to the object file. So if there's any guidance on how that works it would be appreciated!

Also how active is this project? Just because I saw the task stuff is partially implemented so I could potentially fill in some implementations while I'm working on my stuff if I notice any missing

@codimension
Copy link
Contributor

Hey,

For testing in my debugger project, I was using just to copy the Info.plist XML file into the target directory, rather than linking into the executable. In a previous iteration which I lost, I used a makefile with rustc directly to generate the object file, and then deferred to gcc to link in the plist.
I needed a separate build script to sign the executable anyway, but it was a little bit annoying to have to give up on Cargo. Let me know if you figure out anything better!

I was just going to look at the task stuff too, so let me know if you have anything done on it.

I was going to start with task_set_exception_ports and other functions needed for debugging via PTRACE_ATTACHEXC.

I can't chime in on how active the project is however as I've only contributed once.

@xd009642
Copy link
Author

@bythebook oh right so you just used the build.rs to copy it into the same directory as the executable? I'm trying to use this to get cargo-tarpaulin working on mac so I just want to be able to add/remove breakpoints and step/continue them. So if you've got any resources that could help with achieving that I'd also be grateful to be pointed in the right direction 😄

@codimension
Copy link
Contributor

codimension commented Mar 22, 2020

Sorry for the delay, but I tracked back through what I'd done before and wrote it up. I decided to throw up a blog so that when I go through stuff like this I can remember what I did!

Blog is below but the tldr; is you can use the Rust [staticlib] crate type to bundle all Rust dependencies into one unlinked file that you can link with gcc. The downside is

  • having to change the target of your project. If it's not your own project this might make others uncomfortable
  • taking on the responsibility to link the program yourself, and the implications of that if you want people to be able to build with the msvc toolchain on Windows for example.

Full details here.
I think maybe we should close this issue because it's not really related to the mach project at all (but relevant to all its users).

@awakecoding
Copy link

@bythebook it looks the link to your blog post with the answer I'm looking for is a dead link :) can you point me to it? Thanks!

@codimension
Copy link
Contributor

@awakecoding should be back up now, although you've probably moved on since.

This was always a less-than-ideal solution as far as I was concerned. I was having a look at the 'bootimage' crate recently and saw how it created a cargo plugin to build the user's crate and then link it together with a bootloader into one OS bootable image.
If that works, I'm sure it wouldn't be too bad to create something similar to have cargo link in info.plist files or even go further and create MacOS app bundles. I probably won't get a chance to do this myself anytime soon though because I haven't been writing a lot of code recently.

@nvzqz
Copy link

nvzqz commented Jan 10, 2022

Back in Aug 2020 I created embed_plist which places Info.plist into the appropriate section at compile time.

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

No branches or pull requests

4 participants