Don't cleanup the bootstrap update immediately when bootstrapping fails.
[ksplice.git] / kernel-utsname.c
blob4c3d13409d16bf3ce1bde51077cb61b0ff0ade8d
1 /* Copyright (C) 2008-2009 Ksplice, Inc.
2 * Authors: Tim Abbott, Anders Kaseorg, Jeff Arnold
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
15 * 02110-1301, USA.
18 #define _GNU_SOURCE
19 #include "objcommon.h"
20 #include <stdio.h>
22 static void print_section(struct superbfd *sbfd, const char *fieldname,
23 const char *sectname)
25 asection *sect = bfd_get_section_by_name(sbfd->abfd, sectname);
26 assert(sect != NULL);
27 struct supersect *ss = fetch_supersect(sbfd, sect);
28 printf("%s: %s\n", fieldname, read_string(ss, ss->contents.data));
31 int main(int argc, char *argv[])
33 bfd *ibfd;
35 assert(argc >= 1);
36 bfd_init();
37 ibfd = bfd_openr(argv[1], NULL);
38 assert(ibfd);
40 char **matching;
41 assert(bfd_check_format_matches(ibfd, bfd_object, &matching));
43 struct superbfd *sbfd = fetch_superbfd(ibfd);
45 print_section(sbfd, "Sysname", ".uts_sysname");
46 print_section(sbfd, "Machine", ".uts_machine");
47 print_section(sbfd, "Release", ".uts_release");
48 print_section(sbfd, "Version", ".uts_version");
49 return 0;