forked from pkujhd/goloader
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support Go 1.21 (RC3) #19
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61b25c5
to
757a943
Compare
8458c43
to
cea274e
Compare
eh-steve
commented
Jul 19, 2023
Comment on lines
+191
to
+217
// The JIT type's mtyp would have been offset with respect to the new type's module's data base. | ||
// Since the runtime assumes that types and their methods' types are defined in the same module, but we have a situation where the type | ||
// is in the firstmodule, but method type is in a JIT module, we have to hack around runtime.resolveTypeOff | ||
// by adding an entry under a negative offset (< -1) to the firstmodule's typemap | ||
methodType := (*_type)(unsafe.Pointer(cm.module.types + uintptr(prevMethods[i].mtyp))) | ||
firstModuleTypemapCounter-- | ||
if firstmoduledata.typemap == nil { | ||
firstmoduledata.typemap = make(map[typeOff]*_type, len(firstmoduledata.typelinks)+1) | ||
for _, tl := range firstmoduledata.typelinks { | ||
firstmoduledata.typemap[typeOff(tl)] = (*_type)(unsafe.Pointer(firstmoduledata.types + uintptr(tl))) | ||
} | ||
pinnedTypemaps = append(pinnedTypemaps, firstmoduledata.typemap) | ||
} | ||
firstmoduledata.typemap[firstModuleTypemapCounter] = methodType | ||
firstModuleTypemapEntries[methodType] = firstModuleTypemapCounter | ||
|
||
cm.module.typemap[firstModuleTypemapCounter] = methodType // In case we need to resolve this method type with respect to the JIT type (unlikely since it should have been deduped with the firstmodule type?) | ||
methods[i].mtyp = firstModuleTypemapCounter | ||
|
||
err = mprotect.MprotectMakeReadOnly(page) | ||
if err != nil { | ||
return fmt.Errorf("failed to make page read only while patching type %s: %w", _name(t.nameOff(t.str)), err) | ||
} | ||
// Store for later cleanup on Unload() | ||
patchedTypeMethodsMtyp[t][i] = firstModuleTypemapCounter | ||
markedMissing = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fumeboy FYI
61f3cc8
to
2b39c49
Compare
…ning their types are built
… hijack firstmoduledata.typemap to allow resolveTypeOff to find JIT types using a firstmodule base address
… fix bug where inittask package names containing a dot were not properly escaped
…est which involves mutating C initialised data and C calling Go
… wraps handwritten asm with a PUSH/POP BP to create frames for you
c398d9b
to
5c95d7a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses pkujhd#82
TODO:
type: '' for symbol 'io..stmp_2' not found
(caused by reachability analysis incorrectly concluding that static/global vars and their types are not reachable)k8s/protobuf init panic. 1.21 pkg init sequencing is no longer built into the inittasks themselves - the linker is instead responsible for ordering the inittasks correctly, so useAutolib()
orderMacOS without CGo failing (caused by 1.21 automatically wrapping handwritten asm with a PUSH/POP BP to create frames for you)Windows CGo failing (caused by new reloctypes and .bss segments not being handled previouslyMacOS/arm64 CGo missing support for certain native reloc typesmacho.Reloc{Addr:0x58, Value:0x1, Type:0x4, Len:0x2, Pcrel:false, Extern:true, Scattered:false}
MacOS/arm64jit_test.go:1629: failed to load linker: relocation epilogue not available but got a >24-bit CALLARM reloc with offset -387288228: unicode.map.init.0
Linux/arm64 missing support forelf.R_AARCH64_ADR_GOT_PAGE