44 * Copyright (C) 2002-2004 Eric Biederman <[email protected] > 55 */
66
7+ #include <linux/buildid.h>
78#include <linux/crash_core.h>
89#include <linux/utsname.h>
910#include <linux/vmalloc.h>
@@ -378,53 +379,6 @@ phys_addr_t __weak paddr_vmcoreinfo_note(void)
378379}
379380EXPORT_SYMBOL (paddr_vmcoreinfo_note );
380381
381- #define NOTES_SIZE (&__stop_notes - &__start_notes)
382- #define BUILD_ID_MAX SHA1_DIGEST_SIZE
383- #define NT_GNU_BUILD_ID 3
384-
385- struct elf_note_section {
386- struct elf_note n_hdr ;
387- u8 n_data [];
388- };
389-
390- /*
391- * Add build ID from .notes section as generated by the GNU ld(1)
392- * or LLVM lld(1) --build-id option.
393- */
394- static void add_build_id_vmcoreinfo (void )
395- {
396- char build_id [BUILD_ID_MAX * 2 + 1 ];
397- int n_remain = NOTES_SIZE ;
398-
399- while (n_remain >= sizeof (struct elf_note )) {
400- const struct elf_note_section * note_sec =
401- & __start_notes + NOTES_SIZE - n_remain ;
402- const u32 n_namesz = note_sec -> n_hdr .n_namesz ;
403-
404- if (note_sec -> n_hdr .n_type == NT_GNU_BUILD_ID &&
405- n_namesz != 0 &&
406- !strcmp ((char * )& note_sec -> n_data [0 ], "GNU" )) {
407- if (note_sec -> n_hdr .n_descsz <= BUILD_ID_MAX ) {
408- const u32 n_descsz = note_sec -> n_hdr .n_descsz ;
409- const u8 * s = & note_sec -> n_data [n_namesz ];
410-
411- s = PTR_ALIGN (s , 4 );
412- bin2hex (build_id , s , n_descsz );
413- build_id [2 * n_descsz ] = '\0' ;
414- VMCOREINFO_BUILD_ID (build_id );
415- return ;
416- }
417- pr_warn ("Build ID is too large to include in vmcoreinfo: %u > %u\n" ,
418- note_sec -> n_hdr .n_descsz ,
419- BUILD_ID_MAX );
420- return ;
421- }
422- n_remain -= sizeof (struct elf_note ) +
423- ALIGN (note_sec -> n_hdr .n_namesz , 4 ) +
424- ALIGN (note_sec -> n_hdr .n_descsz , 4 );
425- }
426- }
427-
428382static int __init crash_save_vmcoreinfo_init (void )
429383{
430384 vmcoreinfo_data = (unsigned char * )get_zeroed_page (GFP_KERNEL );
@@ -443,7 +397,7 @@ static int __init crash_save_vmcoreinfo_init(void)
443397 }
444398
445399 VMCOREINFO_OSRELEASE (init_uts_ns .name .release );
446- add_build_id_vmcoreinfo ();
400+ VMCOREINFO_BUILD_ID ();
447401 VMCOREINFO_PAGESIZE (PAGE_SIZE );
448402
449403 VMCOREINFO_SYMBOL (init_uts_ns );
0 commit comments