22
22
#include <objtool/elf.h>
23
23
#include <objtool/warn.h>
24
24
25
- #define MAX_NAME_LEN 128
26
-
27
25
static inline u32 str_hash (const char * str )
28
26
{
29
27
return jhash (str , strlen (str ), 0 );
@@ -515,7 +513,7 @@ static int read_symbols(struct elf *elf)
515
513
/* Create parent/child links for any cold subfunctions */
516
514
list_for_each_entry (sec , & elf -> sections , list ) {
517
515
sec_for_each_sym (sec , sym ) {
518
- char pname [ MAX_NAME_LEN + 1 ] ;
516
+ char * pname ;
519
517
size_t pnamelen ;
520
518
if (sym -> type != STT_FUNC )
521
519
continue ;
@@ -531,15 +529,15 @@ static int read_symbols(struct elf *elf)
531
529
continue ;
532
530
533
531
pnamelen = coldstr - sym -> name ;
534
- if (pnamelen > MAX_NAME_LEN ) {
535
- WARN ("%s(): parent function name exceeds maximum length of %d characters" ,
536
- sym -> name , MAX_NAME_LEN );
532
+ pname = strndup (sym -> name , pnamelen );
533
+ if (!pname ) {
534
+ WARN ("%s(): failed to allocate memory" ,
535
+ sym -> name );
537
536
return -1 ;
538
537
}
539
538
540
- strncpy (pname , sym -> name , pnamelen );
541
- pname [pnamelen ] = '\0' ;
542
539
pfunc = find_symbol_by_name (elf , pname );
540
+ free (pname );
543
541
544
542
if (!pfunc ) {
545
543
WARN ("%s(): can't find parent function" ,
0 commit comments