/* The output format to use. */
static const struct output_fns *format = &formats[FORMAT_DEFAULT];
static unsigned int print_format = FORMAT_DEFAULT;
-static const char *print_format_string = NULL;
+static char print_format_string[10];
/* Command options. */
/* Construct a formatting string for printing symbol values. */
-static const char *
-get_print_format (void)
-{
- const char * padding;
- if (print_format == FORMAT_POSIX || print_format == FORMAT_JUST_SYMBOLS)
- {
- /* POSIX compatible output does not have any padding. */
- padding = "";
- }
- else if (print_width == 32)
- {
- padding ="08";
- }
- else /* print_width == 64 */
- {
- padding = "016";
- }
-
- const char * radix = NULL;
- switch (print_radix)
- {
- case 8: radix = PRIo64; break;
- case 10: radix = PRId64; break;
- case 16: radix = PRIx64; break;
- }
-
- return concat ("%", padding, radix, NULL);
-}
-
static void
-set_print_width (bfd *file)
+set_print_format (bfd *file)
{
print_width = bfd_get_arch_size (file);
else
print_width = 32;
}
- free ((char *) print_format_string);
- print_format_string = get_print_format ();
+
+ char *p = print_format_string;
+ *p++ = '%';
+ if (print_format == FORMAT_POSIX || print_format == FORMAT_JUST_SYMBOLS)
+ {
+ /* POSIX compatible output does not have any padding. */
+ }
+ else if (print_width == 32)
+ {
+ *p++ = '0';
+ *p++ = '8';
+ }
+ else /* print_width == 64. */
+ {
+ *p++ = '0';
+ *p++ = '1';
+ *p++ = '6';
+ }
+
+ if (print_width == 32)
+ {
+ switch (print_radix)
+ {
+ case 8: strcpy (p, PRIo32); break;
+ case 10: strcpy (p, PRId32); break;
+ case 16: strcpy (p, PRIx32); break;
+ }
+ }
+ else
+ {
+ switch (print_radix)
+ {
+ case 8: strcpy (p, PRIo64); break;
+ case 10: strcpy (p, PRId64); break;
+ case 16: strcpy (p, PRIx64); break;
+ }
+ }
}
static void
if (bfd_check_format_matches (arfile, bfd_object, &matching))
{
- set_print_width (arfile);
+ set_print_format (arfile);
format->print_archive_member (bfd_get_filename (file),
bfd_get_filename (arfile));
display_rel_file (arfile, file);
}
else if (bfd_check_format_matches (file, bfd_object, &matching))
{
- set_print_width (file);
+ set_print_format (file);
format->print_object_filename (filename);
display_rel_file (file, NULL);
}
switch (print_width)
{
case 32:
+ printf (print_format_string, (uint32_t) val);
+ break;
+
case 64:
printf (print_format_string, (uint64_t) val);
break;