blob: 5adff18e7a26a1e50eae22b0a745b478b7f71eac [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Print contents of object file note.
2 Copyright (C) 2002 Red Hat, Inc.
3 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 This program is Open Source software; you can redistribute it and/or
6 modify it under the terms of the Open Software License version 1.0 as
7 published by the Open Source Initiative.
8
9 You should have received a copy of the Open Software License along
10 with this program; if not, you may obtain a copy of the Open Software
11 License version 1.0 from http://www.opensource.org/licenses/osl.php or
12 by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13 3001 King Ranch Road, Ukiah, CA 95482. */
14
15#ifdef HAVE_CONFIG_H
16# include <config.h>
17#endif
18
19#include <inttypes.h>
20#include <stdio.h>
21#include <string.h>
22#include <libeblP.h>
23
24
25void
26ebl_object_note (ebl, name, type, descsz, desc)
27 Ebl *ebl;
28 const char *name;
29 uint32_t type;
30 uint32_t descsz;
31 const char *desc;
32{
33 if (! ebl->object_note (name, type, descsz, desc))
34 /* The machine specific function did not know this type. */
35 switch (type)
36 {
37 case NT_VERSION:
38 if (strcmp (name, "GNU") == 0 && descsz >= 8)
39 {
40 struct
41 {
42 uint32_t os;
43 uint32_t version[descsz / 4 - 1];
44 } *tag = (__typeof (tag)) desc;
45
46 const char *os;
47 switch (tag->os)
48 {
49 case ELF_NOTE_OS_LINUX:
50 os = "Linux";
51 break;
52
53 case ELF_NOTE_OS_GNU:
54 os = "GNU";
55 break;
56
57 case ELF_NOTE_OS_SOLARIS2:
58 os = "Solaris";
59 break;
60
61 case ELF_NOTE_OS_FREEBSD:
62 os = "FreeBSD";
63 break;
64
65 default:
66 os = "???";
67 break;
68 }
69
70 printf (gettext (" OS: %s, ABI: "), os);
71 size_t cnt;
72 for (cnt = 0; cnt < descsz / 4 - 1; ++cnt)
73 {
74 if (cnt != 0)
75 putchar_unlocked ('.');
76 printf ("%" PRIu32, tag->version[cnt]);
77 }
78 putchar_unlocked ('\n');
79 break;
80 }
81 /* FALLTHROUGH */
82
83 default:
84 /* Unknown type. */
85 break;
86 }
87}