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

Use platform-dependent mcount function #57244

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
6 participants
@quark-zju
Copy link
Contributor

quark-zju commented Jan 1, 2019

Follow up with @nagisa's comment on #57220. Not all platforms use the
mcount name. Added a test.

Use platform-dependent mcount function
Follow up with @nagisa's comment on #57220. Not all platforms use the
`mcount` name. Added a test.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 1, 2019

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

const_cstr!("_mcount")
} else {
const_cstr!("mcount")
};

This comment has been minimized.

@nagisa

nagisa Jan 1, 2019

Contributor

This does not seem to cover it.

Looking at clang’s this->MCountName instances:

  • darwin uses \01mcount;
  • On Aarch64 if abi is gnueabi, \01_mcount is used;
  • On ARM-linux or ARM-unknown if abi is gnueabi \01__gnu_mcount_nc is used and \01mcount if not gnueabi;

Please make this a target property (specified in target files) and use that property here.

This comment has been minimized.

@nagisa

nagisa Jan 1, 2019

Contributor

(I used github search like this. I’m sure it missed some cases as well)

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Jan 1, 2019

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned petrochenkov Jan 1, 2019

@quark-zju

This comment has been minimized.

Copy link
Contributor

quark-zju commented Jan 2, 2019

Thanks for the comments! I was aware of the other mcount names. I didn't add the \01 prefix as I don't fully understand it - When using objdump on an OSX clang -pg binary, it seems \01 prefix got stripped. The clang test didn't test them either (they probably should).

Meanwhile I'm on vacation and have temporarily lost access to fast network, fast machines, and osx platforms. I'll continue work on this when I regain access.

@namhyung

This comment has been minimized.

Copy link

namhyung commented Jan 3, 2019

I also don't know why the \01 prefix is there. But the gnueabi names should be used when it meets the requirements from the ABI. The mcount function in glibc has two arguments - current and parent function addresses. It's architecture dependent how these info will be passed (and be restored if needed).

Please take a look at below:

https://github.com/torvalds/linux/blob/master/arch/arm/kernel/entry-ftrace.S

The tools using the mcount facility (including uftrace) will expect same stack/register layout from the name.

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Jan 3, 2019

I didn't add the \01 prefix as I don't fully understand it - When using objdump on an OSX clang -pg binary, it seems \01 prefix got stripped.

It is usually the case that tools like objdump will demangle the ABI-related symbols.

In any case, I would recommend to just add a target property for now, without worrying about what value would be the most correct for the target. Change only the targets where you’re confident about the difference and leave the other platforms with a default of some sort (e.g. mcount). Target maintainers will end up dealing with it for their target as/if any issues come up.

@Dylan-DPC

This comment has been minimized.

Copy link
Member

Dylan-DPC commented Jan 21, 2019

ping from triage @quark-zju any updates?

@quark-zju

This comment has been minimized.

Copy link
Contributor

quark-zju commented Jan 23, 2019

@Dylan-DPC I'm still on vacation. I'll get back to this next week if everything goes well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment