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

Implement COMDAT support #235

Open
davidlattimore opened this issue Dec 10, 2024 · 0 comments
Open

Implement COMDAT support #235

davidlattimore opened this issue Dec 10, 2024 · 0 comments

Comments

@davidlattimore
Copy link
Owner

I'm somewhat undecided if it's actually worthwhile implementing COMDAT support. I don't really see why it's needed. The idea of COMDAT sections seems to be that you can group multiple sections together then keep or discard those sections as a group. The alternative to COMDAT, which is what Wild currently does, is to take advantage of these symbols being weak. Since they're weak, wild will pick the first definition of the symbol and use that. COMDAT seems to be designed to make sure that we don't mix and match, taking some of a related group of functions / data from one object and others from another object. But even with weak symbols, that should never happen, since we'll pick all of the related weak symbols from the first object that defines them.

Another supposed advantage of COMDAT groups is that the linker discards the duplicate groups, keeping only one. However if you're linking with --gc-sections, then the sections containing duplicate weak symbols will also be discarded, so I'm not sure I buy that as an advantage.

I'd be very interested if someone could show a legitimate use where COMDAT is actually needed. Ideally in a higher level language like C or C++ rather than in assembly and ideally without ODR violations.

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

1 participant