1 /* Print contents of object file note.
2 Copyright (C) 2002, 2007, 2009, 2011 Red Hat, Inc.
3 This file is part of elfutils.
4 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
6 This file is free software; you can redistribute it and/or modify
7 it under the terms of either
9 * the GNU Lesser General Public License as published by the Free
10 Software Foundation; either version 3 of the License, or (at
11 your option) any later version
15 * the GNU General Public License as published by the Free
16 Software Foundation; either version 2 of the License, or (at
17 your option) any later version
19 or both in parallel, as here.
21 elfutils is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <http://www.gnu.org/licenses/>. */
41 ebl_object_note (ebl, name, type, descsz, desc)
48 if (! ebl->object_note (name, type, descsz, desc))
49 /* The machine specific function did not know this type. */
51 if (strcmp ("stapsdt", name) == 0)
55 printf (gettext ("unknown SDT version %u\n"), type);
59 /* Descriptor starts with three addresses, pc, base ref and
60 semaphore. Then three zero terminated strings provider,
61 name and arguments. */
69 size_t addrs_size = gelf_fsize (ebl->elf, ELF_T_ADDR, 3, EV_CURRENT);
70 if (descsz < addrs_size + 3)
73 printf (gettext ("invalid SDT probe descriptor\n"));
79 .d_type = ELF_T_ADDR, .d_version = EV_CURRENT,
80 .d_buf = (void *) desc, .d_size = addrs_size
85 .d_type = ELF_T_ADDR, .d_version = EV_CURRENT,
86 .d_buf = &addrs, .d_size = addrs_size
89 if (gelf_xlatetom (ebl->elf, &dst, &src,
90 elf_getident (ebl->elf, NULL)[EI_DATA]) == NULL)
92 printf ("%s\n", elf_errmsg (-1));
96 const char *provider = desc + addrs_size;
97 const char *pname = memchr (provider, '\0', desc + descsz - provider);
102 const char *args = memchr (pname, '\0', desc + descsz - pname);
104 memchr (++args, '\0', desc + descsz - pname) != desc + descsz - 1)
110 if (gelf_getclass (ebl->elf) == ELFCLASS32)
123 printf (gettext (" PC: "));
124 printf ("%#" PRIx64 ",", pc);
125 printf (gettext (" Base: "));
126 printf ("%#" PRIx64 ",", base);
127 printf (gettext (" Semaphore: "));
128 printf ("%#" PRIx64 "\n", sem);
129 printf (gettext (" Provider: "));
130 printf ("%s,", provider);
131 printf (gettext (" Name: "));
132 printf ("%s,", pname);
133 printf (gettext (" Args: "));
134 printf ("'%s'\n", args);
140 case NT_GNU_BUILD_ID:
141 if (strcmp (name, "GNU") == 0 && descsz > 0)
143 printf (gettext (" Build ID: "));
145 for (i = 0; i < descsz - 1; ++i)
146 printf ("%02" PRIx8, (uint8_t) desc[i]);
147 printf ("%02" PRIx8 "\n", (uint8_t) desc[i]);
151 case NT_GNU_GOLD_VERSION:
152 if (strcmp (name, "GNU") == 0 && descsz > 0)
153 /* A non-null terminated version string. */
154 printf (gettext (" Linker version: %.*s\n"),
159 if (strcmp (name, "GNU") == 0 && descsz >= 8 && descsz % 4 == 0)
163 .d_version = EV_CURRENT,
164 .d_type = ELF_T_WORD,
166 .d_buf = (void *) desc
168 uint32_t buf[descsz / 4];
171 .d_version = EV_CURRENT,
172 .d_type = ELF_T_WORD,
177 if (elf32_xlatetom (&out, &in, ebl->data) != NULL)
182 case ELF_NOTE_OS_LINUX:
186 case ELF_NOTE_OS_GNU:
190 case ELF_NOTE_OS_SOLARIS2:
194 case ELF_NOTE_OS_FREEBSD:
203 printf (gettext (" OS: %s, ABI: "), os);
204 for (size_t cnt = 1; cnt < descsz / 4; ++cnt)
207 putchar_unlocked ('.');
208 printf ("%" PRIu32, buf[cnt]);
210 putchar_unlocked ('\n');