Skip to content

Commit ac353fd

Browse files
Merge pull request ARMmbed#18 from marcuschangarm/optimize-arm
Optimize Arm Compiler
2 parents ee3edbe + 775757c commit ac353fd

File tree

1 file changed

+371
-0
lines changed

1 file changed

+371
-0
lines changed

mbed_printf_armlink_overrides.c

Lines changed: 371 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,371 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Arm Compiler uses dedicated functions for each format specifier used by
19+
* [sn/v/vsn]printf. When minimal-printf overwrites [sn/v/vsn]printf the
20+
* linker is unable to remove unused functions related to printf.
21+
*
22+
* The following stubs replace the built-in functions and helps the linker
23+
* to resolve dependencies and correctly remove unused functions.
24+
*/
25+
26+
#if defined(TOOLCHAIN_ARM)
27+
28+
#include "mbed_printf_implementation.h"
29+
30+
#include <limits.h>
31+
#include <stdio.h>
32+
#include <stdarg.h>
33+
34+
/**
35+
* Arm Compiler uses __2[s/sn/vsn]printf internally.
36+
*/
37+
int $Sub$$__2printf(const char *format, ...)
38+
{
39+
va_list arguments;
40+
va_start(arguments, format);
41+
int result = mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments);
42+
va_end(arguments);
43+
44+
return result;
45+
}
46+
47+
int $Sub$$__2sprintf(char* buffer, const char* format, ...)
48+
{
49+
va_list arguments;
50+
va_start(arguments, format);
51+
int result = mbed_minimal_formatted_string(buffer, LONG_MAX, format, arguments);
52+
va_end(arguments);
53+
54+
return result;
55+
}
56+
57+
int $Sub$$__2snprintf(char* buffer, size_t length, const char* format, ...)
58+
{
59+
va_list arguments;
60+
va_start(arguments, format);
61+
int result = mbed_minimal_formatted_string(buffer, length, format, arguments);
62+
va_end(arguments);
63+
64+
return result;
65+
}
66+
67+
int $Sub$$__2vprintf(char* buffer, const char* format, ...)
68+
{
69+
va_list arguments;
70+
va_start(arguments, format);
71+
int result = mbed_minimal_formatted_string(buffer, LONG_MAX, format, arguments);
72+
va_end(arguments);
73+
74+
return result;
75+
}
76+
77+
int $Sub$$__2vsnprintf(char* buffer, size_t length, const char* format, va_list arguments)
78+
{
79+
return mbed_minimal_formatted_string(buffer, length, format, arguments);
80+
}
81+
82+
/**
83+
* Replace the built-in functions which the linker is unable to prune with dummy stubs
84+
* that take up less space.
85+
*/
86+
int $Sub$$_printf_a(const char *format, ...)
87+
{
88+
return 0;
89+
}
90+
91+
int $Sub$$_printf_c(const char *format, ...)
92+
{
93+
return 0;
94+
}
95+
96+
int $Sub$$_printf_char(const char *format, ...)
97+
{
98+
return 0;
99+
}
100+
101+
int $Sub$$_printf_char_common(const char *format, ...)
102+
{
103+
return 0;
104+
}
105+
106+
int $Sub$$_printf_char_file_locked(const char *format, ...)
107+
{
108+
return 0;
109+
}
110+
111+
int $Sub$$_printf_charcount(const char *format, ...)
112+
{
113+
return 0;
114+
}
115+
116+
int $Sub$$_printf_cs_common(const char *format, ...)
117+
{
118+
return 0;
119+
}
120+
121+
int $Sub$$_printf_d(const char *format, ...)
122+
{
123+
return 0;
124+
}
125+
126+
int $Sub$$_printf_dec(const char *format, ...)
127+
{
128+
return 0;
129+
}
130+
131+
int $Sub$$_printf_e(const char *format, ...)
132+
{
133+
return 0;
134+
}
135+
136+
int $Sub$$_printf_f(const char *format, ...)
137+
{
138+
return 0;
139+
}
140+
141+
int $Sub$$_printf_fp_dec(const char *format, ...)
142+
{
143+
return 0;
144+
}
145+
146+
int $Sub$$_printf_fp_dec_real(const char *format, ...)
147+
{
148+
return 0;
149+
}
150+
151+
int $Sub$$_printf_fp_hex(const char *format, ...)
152+
{
153+
return 0;
154+
}
155+
156+
int $Sub$$_printf_fp_hex_real(const char *format, ...)
157+
{
158+
return 0;
159+
}
160+
161+
int $Sub$$_printf_fp_infnan(const char *format, ...)
162+
{
163+
return 0;
164+
}
165+
166+
int $Sub$$_printf_g(const char *format, ...)
167+
{
168+
return 0;
169+
}
170+
171+
int $Sub$$_printf_hex_int_ll_ptr(const char *format, ...)
172+
{
173+
return 0;
174+
}
175+
176+
int $Sub$$_printf_hex_ptr(const char *format, ...)
177+
{
178+
return 0;
179+
}
180+
181+
int $Sub$$_printf_i(const char *format, ...)
182+
{
183+
return 0;
184+
}
185+
186+
int $Sub$$_printf_int_common(const char *format, ...)
187+
{
188+
return 0;
189+
}
190+
191+
int $Sub$$_printf_int_dec(const char *format, ...)
192+
{
193+
return 0;
194+
}
195+
196+
int $Sub$$_printf_int_hex(const char *format, ...)
197+
{
198+
return 0;
199+
}
200+
201+
int $Sub$$_printf_int_oct(const char *format, ...)
202+
{
203+
return 0;
204+
}
205+
206+
int $Sub$$_printf_l(const char *format, ...)
207+
{
208+
return 0;
209+
}
210+
211+
int $Sub$$_printf_lc(const char *format, ...)
212+
{
213+
return 0;
214+
}
215+
216+
int $Sub$$_printf_lcs_common(const char *format, ...)
217+
{
218+
return 0;
219+
}
220+
221+
int $Sub$$_printf_ll(const char *format, ...)
222+
{
223+
return 0;
224+
}
225+
226+
int $Sub$$_printf_ll_hex(const char *format, ...)
227+
{
228+
return 0;
229+
}
230+
231+
int $Sub$$_printf_ll_oct(const char *format, ...)
232+
{
233+
return 0;
234+
}
235+
236+
int $Sub$$_printf_lld(const char *format, ...)
237+
{
238+
return 0;
239+
}
240+
241+
int $Sub$$_printf_lli(const char *format, ...)
242+
{
243+
return 0;
244+
}
245+
246+
int $Sub$$_printf_llo(const char *format, ...)
247+
{
248+
return 0;
249+
}
250+
251+
int $Sub$$_printf_llu(const char *format, ...)
252+
{
253+
return 0;
254+
}
255+
256+
int $Sub$$_printf_llx(const char *format, ...)
257+
{
258+
return 0;
259+
}
260+
261+
int $Sub$$_printf_longlong_dec(const char *format, ...)
262+
{
263+
return 0;
264+
}
265+
266+
int $Sub$$_printf_longlong_hex(const char *format, ...)
267+
{
268+
return 0;
269+
}
270+
271+
int $Sub$$_printf_longlong_oct(const char *format, ...)
272+
{
273+
return 0;
274+
}
275+
276+
int $Sub$$_printf_ls(const char *format, ...)
277+
{
278+
return 0;
279+
}
280+
281+
int $Sub$$_printf_n(const char *format, ...)
282+
{
283+
return 0;
284+
}
285+
286+
int $Sub$$_printf_o(const char *format, ...)
287+
{
288+
return 0;
289+
}
290+
291+
int $Sub$$_printf_oct_int_ll(const char *format, ...)
292+
{
293+
return 0;
294+
}
295+
296+
int $Sub$$_printf_p(const char *format, ...)
297+
{
298+
return 0;
299+
}
300+
301+
int $Sub$$_printf_pad(const char *format, ...)
302+
{
303+
return 0;
304+
}
305+
306+
int $Sub$$_printf_percent(const char *format, ...)
307+
{
308+
return 0;
309+
}
310+
311+
int $Sub$$_printf_percent_end(const char *format, ...)
312+
{
313+
return 0;
314+
}
315+
316+
int $Sub$$_printf_s(const char *format, ...)
317+
{
318+
return 0;
319+
}
320+
321+
int $Sub$$_printf_str(const char *format, ...)
322+
{
323+
return 0;
324+
}
325+
326+
int $Sub$$_printf_string(const char *format, ...)
327+
{
328+
return 0;
329+
}
330+
331+
int $Sub$$_printf_truncate(const char *format, ...)
332+
{
333+
return 0;
334+
}
335+
336+
int $Sub$$_printf_truncate_signed(const char *format, ...)
337+
{
338+
return 0;
339+
}
340+
341+
int $Sub$$_printf_truncate_unsigned(const char *format, ...)
342+
{
343+
return 0;
344+
}
345+
346+
int $Sub$$_printf_u(const char *format, ...)
347+
{
348+
return 0;
349+
}
350+
351+
int $Sub$$_printf_wchar(const char *format, ...)
352+
{
353+
return 0;
354+
}
355+
356+
int $Sub$$_printf_wctomb(const char *format, ...)
357+
{
358+
return 0;
359+
}
360+
361+
int $Sub$$_printf_wstring(const char *format, ...)
362+
{
363+
return 0;
364+
}
365+
366+
int $Sub$$_printf_x(const char *format, ...)
367+
{
368+
return 0;
369+
}
370+
371+
#endif

0 commit comments

Comments
 (0)