]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Cleanups in libasm abd objdump.
authorUlrich Drepper <drepper@redhat.com>
Fri, 11 Jan 2008 10:12:18 +0000 (10:12 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 11 Jan 2008 10:12:18 +0000 (10:12 +0000)
libcpu/ChangeLog
libcpu/i386_data.h
libcpu/i386_disasm.c
src/ChangeLog
src/objdump.c

index cbfcd755609eff64ffea51e65a0f5fab3caa6639..cb0f4edfa67a869fe97f6dac592cbaa81f3831f7 100644 (file)
@@ -2,6 +2,8 @@
 
        * i386_disasm.c (i386_disasm): Resize output buffer if necessary.
        Optimize output_data initialization.  Free buffers before return.
+       (struct output_data): Remove op1str field.  Adjust code.
+       (i386_disasm): Store final NUL btye at end of functions.
 
 2008-01-10  Ulrich Drepper  <drepper@redhat.com>
 
index 5f66c610f71ad7cd7121f0536e78526ec7de4475..89fa3089f18d8f31c14a90cf98a44a5368ee8967 100644 (file)
@@ -1,4 +1,4 @@
-/* Helper routines for disassembler for x86-64.
+/* Helper routines for disassembler for x86/x86-64.
    Copyright (C) 2007, 2008 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2007.
index dd7bfca4a16511963e885cf06a2ed715e57731ef..2a843923a3356f0bd7ca959c3941f3e229593b39 100644 (file)
@@ -188,7 +188,6 @@ struct output_data
 {
   GElf_Addr addr;
   int *prefixes;
-  const char *op1str;
   size_t opoff1;
   size_t opoff2;
   size_t opoff3;
@@ -467,9 +466,6 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
              data = begin + 1;
              ++addr;
 
-             /* The string definitely fits.  */
-             buf[bufcnt++] = '\0';
-
              goto out;
            }
 
@@ -659,6 +655,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                    {
                    case suffix_none:
                      break;
+
                    case suffix_w:
                      if ((codep[-1] & 0xc0) != 0xc0)
                        {
@@ -681,14 +678,17 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                          ADD_CHAR (ch);
                        }
                      break;
+
                    case suffix_w0:
                      if ((codep[-1] & 0xc0) != 0xc0)
                        ADD_CHAR ('l');
                      break;
+
                    case suffix_w1:
                      if ((data[0] & 0x4) == 0)
                        ADD_CHAR ('l');
                      break;
+
                    case suffix_W:
                      if (prefixes & has_data16)
                        {
@@ -700,6 +700,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                        ADD_CHAR ('q');
 #endif
                      break;
+
                    case suffix_W1:
                      if (prefixes & has_data16)
                        {
@@ -720,10 +721,12 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                        };
                      ADD_STRING (tttn[codep[-1 - instrtab[cnt].modrm] & 0x0f]);
                      break;
+
                    case suffix_D:
                      if ((codep[-1] & 0xc0) != 0xc0)
                        ADD_CHAR ((data[0] & 0x04) == 0 ? 's' : 'l');
                      break;
+
                    default:
                      printf("unknown suffix %d\n", instrtab[cnt].suffix);
                      abort ();
@@ -739,7 +742,6 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                      if (instrtab[cnt].str1 != 0)
                        ADD_STRING (op1_str[instrtab[cnt].str1]);
 
-                     output_data.op1str = op1_str[instrtab[cnt].str1];
                      output_data.opoff1 = (instrtab[cnt].off1_1
                                            + OFF1_1_BIAS - opoff);
                      output_data.opoff2 = (instrtab[cnt].off1_2
@@ -752,7 +754,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                      if (r > 0)
                        goto enomem;
 
-                     string_end_idx = ~0ul;
+                     string_end_idx = bufcnt;
                    }
                  else if (prec == 2 && instrtab[cnt].fct2 != 0)
                    {
@@ -760,7 +762,6 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                      if (instrtab[cnt].str2 != 0)
                        ADD_STRING (op2_str[instrtab[cnt].str2]);
 
-                     output_data.op1str = op2_str[instrtab[cnt].str2];
                      output_data.opoff1 = (instrtab[cnt].off2_1
                                            + OFF2_1_BIAS - opoff);
                      output_data.opoff2 = (instrtab[cnt].off2_2
@@ -773,7 +774,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                      if (r > 0)
                        goto enomem;
 
-                     string_end_idx = ~0ul;
+                     string_end_idx = bufcnt;
                    }
                  else if (prec == 3 && instrtab[cnt].fct3 != 0)
                    {
@@ -781,7 +782,6 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                      if (instrtab[cnt].str3 != 0)
                        ADD_STRING (op3_str[instrtab[cnt].str3]);
 
-                     output_data.op1str = op3_str[instrtab[cnt].str3];
                      output_data.opoff1 = (instrtab[cnt].off3_1
                                            + OFF3_1_BIAS - opoff);
                      output_data.opoff2 = (instrtab[cnt].off3_2
@@ -798,17 +798,9 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                      if (r > 0)
                        goto enomem;
 
-                     string_end_idx = ~0ul;
+                     string_end_idx = bufcnt;
                    }
                  break;
-
-               case 'e':
-                 /* String end marker.  */
-                 if (string_end_idx == ~0ul)
-                   string_end_idx = bufcnt;
-                 /* No padding.  */
-                 width = 0;
-                 break;
                }
 
              /* Pad according to the specified width.  */
@@ -820,8 +812,8 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
          if ((prefixes & SEGMENT_PREFIXES) != 0)
            goto print_prefix;
 
-         if (string_end_idx != ~0ul)
-           buf[string_end_idx] = '\0';
+         assert (string_end_idx != ~0ul);
+         bufcnt = string_end_idx;
 
          addr += param_start - begin;
          data = param_start;
@@ -837,11 +829,13 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
       ADD_STRING ("(bad)");
       addr += data - begin;
 
-      buf[bufcnt++] = '\0';
-
     out:
+      if (bufcnt == bufsize)
+       goto enomem;
+      buf[bufcnt] = '\0';
+
       *startp = data;
-      retval = outcb (buf, strlen (buf), outcbarg);
+      retval = outcb (buf, bufcnt, outcbarg);
       if (retval != 0)
        goto do_ret;
     }
index aa9b624193ec2f57ec829156501d26ff6415f997..aeb501bde385f4e9544a24ee6e374682f196f103 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-11  Ulrich Drepper  <drepper@redhat.com>
+
+       * objdump.c (show_disasm): Adjust disassembler format string for
+       removal of %e.
+
 2008-01-04  Roland McGrath  <roland@redhat.com>
 
        * strip.c (handle_elf): Move SHDRIDX defn to silence gcc warning.
index 92ab84f822a6f01de75dd2bd26589852857eba74..7b95ddd628d1e939b29dd94fe64d2b55dbb389db 100644 (file)
@@ -756,7 +756,8 @@ show_disasm (Ebl *ebl, const char *fname, uint32_t shstrndx)
          info.last_end = info.cur = data->d_buf;
 
          disasm_cb (ctx, &info.cur, info.cur + data->d_size, info.addr,
-                    "%7m%e %.1o%e,%.2o%e,%.3o%e", disasm_output, &info,
+                    //"%7m%e %.1o%e,%.2o%e,%.3o%e", disasm_output, &info,
+                    "%7m %.1o,%.2o,%.3o", disasm_output, &info,
                     NULL /* XXX */);
        }
     }