Skip to content

Commit 9807779

Browse files
committed
fix: ipsw dsc disass --demangle support + minor fixes
1 parent 6eaeabc commit 9807779

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

cmd/ipsw/cmd/dyld/dyld_disass.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ var DisassCmd = &cobra.Command{
179179
return nil
180180
}
181181

182-
if !quiet && len(symbolName) > 0 {
182+
if !quiet || len(symbolName) > 0 {
183183
if len(cacheFile) == 0 {
184184
cacheFile = dscPath + ".a2s"
185185
}

pkg/disass/disass.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,10 @@ func Disassemble(d Disass) string {
268268
}
269269
}
270270

271-
if swiftstr, ok := d.FindSwiftString(instruction.Address); ok {
272-
comment = fmt.Sprintf(" ; %#v", swiftstr)
271+
if instruction.Address != startAddr {
272+
if swiftstr, ok := d.FindSwiftString(instruction.Address); ok {
273+
comment = fmt.Sprintf(" ; %#v", swiftstr)
274+
}
273275
}
274276

275277
// if ok, imm := triage.HasLoc(i.Instruction.Address()); ok {

pkg/dyld/image.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,11 @@ func (i *CacheImage) GetPartialMacho() (*macho.File, error) {
532532
// Analyze analyzes an image by parsing it's symbols, stubs and GOT
533533
func (i *CacheImage) Analyze() error {
534534

535+
if err := i.ParseObjC(); err != nil {
536+
log.Errorf("failed to parse objc data for image %s: %v", filepath.Base(i.Name), err)
537+
// return fmt.Errorf("failed to parse objc data for image %s: %v", filepath.Base(i.Name), err) FIXME: should this error out?
538+
}
539+
535540
if err := i.ParsePublicSymbols(false); err != nil {
536541
log.Errorf("failed to parse exported symbols for %s: %w", i.Name, err)
537542
}
@@ -542,11 +547,6 @@ func (i *CacheImage) Analyze() error {
542547
}
543548
}
544549

545-
if err := i.ParseObjC(); err != nil {
546-
log.Errorf("failed to parse objc data for image %s: %v", filepath.Base(i.Name), err)
547-
// return fmt.Errorf("failed to parse objc data for image %s: %v", filepath.Base(i.Name), err) FIXME: should this error out?
548-
}
549-
550550
if !i.cache.IsArm64() {
551551
utils.Indent(log.Warn, 2)("image analysis of stubs and GOT only works on arm64 architectures")
552552
}

pkg/dyld/symbols.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,7 @@ func (f *File) OpenOrCreateA2SCache(cacheFile string) error {
382382
}
383383
for stub, target := range f.islandStubs {
384384
if symName, ok := f.AddressToSymbol[target]; ok {
385-
if !strings.HasPrefix(symName, "j_") {
386-
f.AddressToSymbol[stub] = "j_" + strings.TrimPrefix(symName, "__stub_helper.")
387-
} else {
388-
f.AddressToSymbol[stub] = symName
389-
}
385+
f.AddressToSymbol[stub] = symName
390386
}
391387
}
392388
}

0 commit comments

Comments
 (0)