Only use COW hooks in diff mode.
[ksplice.git] / kernel-utsname.c
blob9484a68f51185cc750419c4ce199e07a5cd11948
1 /* Copyright (C) 2008 Tim Abbott <tabbott@mit.edu>,
2 * Anders Kaseorg <andersk@mit.edu>,
3 * Jeffrey Brian Arnold <jbarnold@mit.edu>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License, version 2.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
16 * 02110-1301, USA.
19 #define _GNU_SOURCE
20 #include "objcommon.h"
21 #include <stdio.h>
23 static void print_section(struct superbfd *sbfd, const char *fieldname,
24 const char *sectname)
26 asection *sect = bfd_get_section_by_name(sbfd->abfd, sectname);
27 assert(sect != NULL);
28 struct supersect *ss = fetch_supersect(sbfd, sect);
29 printf("%s: %s\n", fieldname, read_string(ss, ss->contents.data));
32 int main(int argc, char *argv[])
34 bfd *ibfd;
36 assert(argc >= 1);
37 bfd_init();
38 ibfd = bfd_openr(argv[1], NULL);
39 assert(ibfd);
41 char **matching;
42 assert(bfd_check_format_matches(ibfd, bfd_object, &matching));
44 struct superbfd *sbfd = fetch_superbfd(ibfd);
46 print_section(sbfd, "Sysname", ".uts_sysname");
47 print_section(sbfd, "Machine", ".uts_machine");
48 print_section(sbfd, "Release", ".uts_release");
49 print_section(sbfd, "Version", ".uts_version");
50 return 0;