-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add support for deduplicating type descriptors by relocating code to point at main module's types #62
Conversation
…point at main module's types
… (fixes cases where import path doesn't match the local package name)
8de31ce
to
c1bcb52
Compare
… assist in debugging + fix cutab layout to correctly offset when creating multi-object, multi-package linkers - previously stack traces had incorrect files due to incorrect cutab + filetab
… instead of string equality
@eh-steve, thanks for your pr, but some changes cannot adapt to the lower golang version, i will review it and merge it manually. |
I'm happy to port the pclntab changes to the lower versions - I might be making some more changes once I get to the bottom of some other bugs |
When the loader adds a symbol (ld.go:AddSymbol), if the symbol already exists in loader, the loader will be use the symbol in loader, it will be avoid to duplicate type symbol, but it will be lead to far address for R_ADDR on windows platform. |
I will merge bug fix manually, thanks for your pr |
Hi, your fixes don't actually cover everything that has been fixed in this PR - would you be up for discussing these changes further? I might add some tests which demonstrate each fix |
@eh-steve |
Hi @pkujhd, I've opened a chunky PR which hopefully demonstrates the purpose of each commit (and adds a new JIT compiler package). The I would suggest we try to fix all the outstanding goloader bugs in that branch, then attempt to backport the changes for older Go versions rather than picking individual commits into master which aren't 100% working. |
Previously, compiled code which used type assertions or switches wouldn't always work as expected, since duplicate
*_type
s would be present in both the main module and the object file, and type assertion uses pointer equality to determine whether types match (and the object code would reference the local types)This PR relocates code which references identical type descriptors (according to their compiler generated type hash being identical and type definitions being identical according to
runtime.typesEqual()
) to point at the main module's*_type
s:Example
might previously fail with
interface conversion: interface {} is []uint8, not []uint8 (types from different scopes)
, even if the incoming input is a[]byte
.Instead, in these cases you had to use reflection to (safely) extract the underlying concrete type from the interface, e.g.:
This PR fixed the broken behaviour so type assertion and type switches on duplicated types works as expected