@@ -9,6 +9,7 @@ export class ElfParser {
99 private symbolTable ! : Buffer ;
1010 private symbolStringTable ! : Buffer ;
1111 private is64Bit : boolean = false ;
12+ private symbols : Symbol [ ] = [ ] ;
1213
1314 constructor ( filePath : string ) {
1415 this . buffer = fs . readFileSync ( filePath ) ;
@@ -146,7 +147,7 @@ export class ElfParser {
146147 }
147148
148149 private getSectionName ( index : number ) : string {
149- if ( ! this . stringTable ) return '' ;
150+ if ( ! this . stringTable ) { return '' ; }
150151 return this . getString ( this . stringTable , index ) ;
151152 }
152153
@@ -169,6 +170,9 @@ export class ElfParser {
169170 }
170171
171172 public getAllSymbols ( ) : Symbol [ ] {
173+ if ( this . symbols . length > 0 ) {
174+ return this . symbols ;
175+ }
172176 if ( ! this . symbolTable || ! this . symbolStringTable ) {
173177 return [ ] ;
174178 }
@@ -202,10 +206,10 @@ export class ElfParser {
202206 }
203207
204208 const size = Number ( entry . size ) ;
205- if ( size === 0 ) continue ; // Skip symbols with zero size
209+ if ( size === 0 ) { continue ; } // Skip symbols with zero size
206210
207211 const name = this . getString ( this . symbolStringTable , entry . name ) ;
208- if ( ! name ) continue ;
212+ if ( ! name ) { continue ; }
209213
210214 const type = this . getSymbolType ( entry . info ) ;
211215 const sectionName = this . getSectionNameByIndex ( entry . shndx ) ;
@@ -219,7 +223,9 @@ export class ElfParser {
219223 } ) ;
220224 }
221225
222- return symbols . sort ( ( a , b ) => b . size - a . size ) ;
226+
227+ this . symbols = symbols . sort ( ( a , b ) => b . size - a . size ) ;
228+ return this . symbols ;
223229 }
224230
225231 public getSymbolsBySection ( sectionName : string ) : Symbol [ ] {
0 commit comments