llvm.org GIT mirror llvm / d712968
[llvm-nm] Add -radix option Differential Revision: http://reviews.llvm.org/D16822 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260392 91177308-0d34-0410-b5e6-96231b3b80d8 Hemant Kulkarni 3 years ago
5 changed file(s) with 302 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
125125
126126 Print only symbols referenced but not defined in this file.
127127
128 .. option:: --radix=RADIX, -t
129
130 Specify the radix of the symbol address(es). Values accepted d(decimal),
131 x(hexadecomal) and o(octal).
132
128133 BUGS
129134 ----
130135
0 .text
1 .file "1.c"
2 .type i0,@object # @i0
3 .bss
4 .globl i0
5 .align 4
6 i0:
7 .long 0 # 0x0
8 .size i0, 4
9
10 .type i1,@object # @i1
11 .data
12 .globl i1
13 .align 4
14 i1:
15 .long 1 # 0x1
16 .size i1, 4
17
18 .type i2,@object # @i2
19 .globl i2
20 .align 4
21 i2:
22 .long 2 # 0x2
23 .size i2, 4
24
25 .type i3,@object # @i3
26 .globl i3
27 .align 4
28 i3:
29 .long 3 # 0x3
30 .size i3, 4
31
32 .type i4,@object # @i4
33 .globl i4
34 .align 4
35 i4:
36 .long 4 # 0x4
37 .size i4, 4
38
39 .type i5,@object # @i5
40 .globl i5
41 .align 4
42 i5:
43 .long 5 # 0x5
44 .size i5, 4
45
46 .type i6,@object # @i6
47 .globl i6
48 .align 4
49 i6:
50 .long 6 # 0x6
51 .size i6, 4
52
53 .type i7,@object # @i7
54 .globl i7
55 .align 4
56 i7:
57 .long 7 # 0x7
58 .size i7, 4
59
60 .type i8,@object # @i8
61 .globl i8
62 .align 4
63 i8:
64 .long 8 # 0x8
65 .size i8, 4
66
67 .type i9,@object # @i9
68 .globl i9
69 .align 4
70 i9:
71 .long 9 # 0x9
72 .size i9, 4
73
74 .type i10,@object # @i10
75 .globl i10
76 .align 4
77 i10:
78 .long 10 # 0xa
79 .size i10, 4
80
81 .type i11,@object # @i11
82 .globl i11
83 .align 4
84 i11:
85 .long 11 # 0xb
86 .size i11, 4
87
88 .type i12,@object # @i12
89 .globl i12
90 .align 4
91 i12:
92 .long 12 # 0xc
93 .size i12, 4
94
95 .type i13,@object # @i13
96 .globl i13
97 .align 4
98 i13:
99 .long 13 # 0xd
100 .size i13, 4
101
102 .type i14,@object # @i14
103 .globl i14
104 .align 4
105 i14:
106 .long 14 # 0xe
107 .size i14, 4
108
109 .type i15,@object # @i15
110 .globl i15
111 .align 4
112 i15:
113 .long 15 # 0xf
114 .size i15, 4
115
116 .type i16,@object # @i16
117 .globl i16
118 .align 4
119 i16:
120 .long 16 # 0x10
121 .size i16, 4
122
123 .type i17,@object # @i17
124 .globl i17
125 .align 4
126 i17:
127 .long 17 # 0x11
128 .size i17, 4
129
130 .type i18,@object # @i18
131 .globl i18
132 .align 4
133 i18:
134 .long 18 # 0x12
135 .size i18, 4
136
137 .type i19,@object # @i19
138 .globl i19
139 .align 4
140 i19:
141 .long 19 # 0x13
142 .size i19, 4
143
144 .type i20,@object # @i20
145 .globl i20
146 .align 4
147 i20:
148 .long 20 # 0x14
149 .size i20, 4
150
151 .type i21,@object # @i21
152 .globl i21
153 .align 4
154 i21:
155 .long 21 # 0x15
156 .size i21, 4
157
158 .type i22,@object # @i22
159 .globl i22
160 .align 4
161 i22:
162 .long 22 # 0x16
163 .size i22, 4
164
165 .type i23,@object # @i23
166 .globl i23
167 .align 4
168 i23:
169 .long 23 # 0x17
170 .size i23, 4
171
172 .type i24,@object # @i24
173 .globl i24
174 .align 4
175 i24:
176 .long 24 # 0x18
177 .size i24, 4
178
179
180 .ident "clang version 3.6.0 (tags/RELEASE_360/final)"
181 .section ".note.GNU-stack","",@progbits
0 if not 'X86' in config.root.targets:
1 config.unsupported = True
0 #check radix formats of llvm-nm
1 RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/radix.asm -o %t.o
2 RUN: llvm-nm -radix=d %t.o | FileCheck %s
3 RUN: llvm-nm -radix=o %t.o | FileCheck --check-prefix="OCTAL" %s
4 RUN: llvm-nm -t=x %t.o | FileCheck --check-prefix="HEX" %s
5
6 CHECK: 0000000000000000 B i0
7 CHECK: 0000000000000000 D i1
8 CHECK: 0000000000000036 D i10
9 CHECK: 0000000000000040 D i11
10 CHECK: 0000000000000044 D i12
11 CHECK: 0000000000000048 D i13
12 CHECK: 0000000000000052 D i14
13 CHECK: 0000000000000056 D i15
14 CHECK: 0000000000000060 D i16
15 CHECK: 0000000000000064 D i17
16 CHECK: 0000000000000068 D i18
17 CHECK: 0000000000000072 D i19
18 CHECK: 0000000000000004 D i2
19 CHECK: 0000000000000076 D i20
20 CHECK: 0000000000000080 D i21
21 CHECK: 0000000000000084 D i22
22 CHECK: 0000000000000088 D i23
23 CHECK: 0000000000000092 D i24
24 CHECK: 0000000000000008 D i3
25 CHECK: 0000000000000012 D i4
26 CHECK: 0000000000000016 D i5
27 CHECK: 0000000000000020 D i6
28 CHECK: 0000000000000024 D i7
29 CHECK: 0000000000000028 D i8
30 CHECK: 0000000000000032 D i9
31
32 OCTAL: 0000000000000000 B i0
33 OCTAL: 0000000000000000 D i1
34 OCTAL: 0000000000000044 D i10
35 OCTAL: 0000000000000050 D i11
36 OCTAL: 0000000000000054 D i12
37 OCTAL: 0000000000000060 D i13
38 OCTAL: 0000000000000064 D i14
39 OCTAL: 0000000000000070 D i15
40 OCTAL: 0000000000000074 D i16
41 OCTAL: 0000000000000100 D i17
42 OCTAL: 0000000000000104 D i18
43 OCTAL: 0000000000000110 D i19
44 OCTAL: 0000000000000004 D i2
45 OCTAL: 0000000000000114 D i20
46 OCTAL: 0000000000000120 D i21
47 OCTAL: 0000000000000124 D i22
48 OCTAL: 0000000000000130 D i23
49 OCTAL: 0000000000000134 D i24
50 OCTAL: 0000000000000010 D i3
51 OCTAL: 0000000000000014 D i4
52 OCTAL: 0000000000000020 D i5
53 OCTAL: 0000000000000024 D i6
54 OCTAL: 0000000000000030 D i7
55 OCTAL: 0000000000000034 D i8
56 OCTAL: 0000000000000040 D i9
57
58 HEX: 0000000000000000 B i0
59 HEX: 0000000000000000 D i1
60 HEX: 0000000000000024 D i10
61 HEX: 0000000000000028 D i11
62 HEX: 000000000000002c D i12
63 HEX: 0000000000000030 D i13
64 HEX: 0000000000000034 D i14
65 HEX: 0000000000000038 D i15
66 HEX: 000000000000003c D i16
67 HEX: 0000000000000040 D i17
68 HEX: 0000000000000044 D i18
69 HEX: 0000000000000048 D i19
70 HEX: 0000000000000004 D i2
71 HEX: 000000000000004c D i20
72 HEX: 0000000000000050 D i21
73 HEX: 0000000000000054 D i22
74 HEX: 0000000000000058 D i23
75 HEX: 000000000000005c D i24
76 HEX: 0000000000000008 D i3
77 HEX: 000000000000000c D i4
78 HEX: 0000000000000010 D i5
79 HEX: 0000000000000014 D i6
80 HEX: 0000000000000018 D i7
81 HEX: 000000000000001c D i8
82 HEX: 0000000000000020 D i9
136136 cl::opt ArchiveMap("print-armap", cl::desc("Print the archive map"));
137137 cl::alias ArchiveMaps("M", cl::desc("Alias for --print-armap"),
138138 cl::aliasopt(ArchiveMap), cl::Grouping);
139
140 enum Radix { d, o, x };
141 cl::opt
142 AddressRadix("radix", cl::desc("Radix (o/d/x) for printing symbol Values"),
143 cl::values(clEnumVal(d, "decimal"), clEnumVal(o, "octal"),
144 clEnumVal(x, "hexadecimal"), clEnumValEnd),
145 cl::init(x));
146 cl::alias RadixAlias("t", cl::desc("Alias for --radix"),
147 cl::aliasopt(AddressRadix));
139148
140149 cl::opt JustSymbolName("just-symbol-name",
141150 cl::desc("Print just the symbol's name"));
571580 if (isSymbolList64Bit(Obj)) {
572581 printBlanks = " ";
573582 printDashes = "----------------";
574 printFormat = "%016" PRIx64;
583 switch (AddressRadix) {
584 case Radix::o:
585 printFormat = "%016" PRIo64;
586 break;
587 case Radix::x:
588 printFormat = "%016" PRIx64;
589 break;
590 default:
591 printFormat = "%016" PRId64;
592 }
575593 } else {
576594 printBlanks = " ";
577595 printDashes = "--------";
578 printFormat = "%08" PRIx64;
596 switch (AddressRadix) {
597 case Radix::o:
598 printFormat = "%08" PRIo64;
599 break;
600 case Radix::x:
601 printFormat = "%08" PRIx64;
602 break;
603 default:
604 printFormat = "%08" PRId64;
605 }
579606 }
580607
581608 for (SymbolListT::iterator I = SymbolList.begin(), E = SymbolList.end();
942969 std::error_code EC = Sym.printName(OS);
943970 if (EC && MachO)
944971 OS << "bad string index";
945 else
972 else
946973 error(EC);
947974 OS << '\0';
948975 S.Sym = Sym;