From patchwork Thu Nov 22 17:38:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 30262 Received: (qmail 35066 invoked by alias); 22 Nov 2018 17:38:19 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 34956 invoked by uid 89); 22 Nov 2018 17:38:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*RU:sk:mail-pg, Hx-spam-relays-external:sk:mail-pg, HX-HELO:sk:mail-pg, HX-Received:b4c X-HELO: mail-pg1-f170.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=p8X0lTGgXl/uGXhfhB4YD912zdxM2ukPVLJnx/6WMmA=; b=DbC2CmZTc1ywm9P949Wm80Bn5QlSpvZkBoky4ncUwa09/ZftJF5po4q15giywgtwIf GFnXQcjkVz4k9cfvllTpXwr9ONH7dBw0eF+fY82jbaUw+hymlJWRC1grYkSbWiWMU6fx H7TzWy0YgXQq48R0+T0IyULhXE04J+36b+FDPuNr2xa8Jk8iwzm7iP931pzmWsS5fIzw vqNtON3+RzSKnK0IXYIWqcPLQSVyB8x8fYxPWgq7IOKv5q9Xz29ntkeGZwLsf2p6qiq7 zoWXDUmCwpEjuzkhOAVyUB5UbMQaU3wsJrxauwOcNBVXhaDD+23hkU+C1Zc0f3GiVAl2 RUgQ== Return-Path: From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH] _dl_exception_create_format: Support %x/%lx/%Zx Date: Thu, 22 Nov 2018 09:38:12 -0800 Message-Id: <20181122173812.9025-1-hjl.tools@gmail.com> MIME-Version: 1.0 Add support for %x, %lx and %Zx to _dl_exception_create_format and pad to the full width with 0. * elf/dl-exception.c (_dl_exception_create_format): Support %x, %lx and %Zx. --- elf/dl-exception.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/elf/dl-exception.c b/elf/dl-exception.c index 1c63e4a3a6..2144998261 100644 --- a/elf/dl-exception.c +++ b/elf/dl-exception.c @@ -111,6 +111,20 @@ _dl_exception_create_format (struct dl_exception *exception, const char *objname case 's': length += strlen (va_arg (ap, const char *)); break; + /* Recognize the l modifier. It is only important on some + platforms where long and int have a different size. We + can use the same code for size_t. */ + case 'l': + case 'Z': + if (p[1] == 'x') + { + length += LONG_WIDTH / 4; + ++p; + break; + } + case 'x': + length += INT_WIDTH / 4; + break; default: /* Assumed to be '%'. */ ++length; @@ -167,6 +181,32 @@ _dl_exception_create_format (struct dl_exception *exception, const char *objname *wptr = '%'; ++wptr; break; + case 'x': + { + unsigned long int num = va_arg (ap, unsigned int); + char *start = wptr; + wptr += INT_WIDTH / 4; + char *cp = _itoa (num, wptr, 16, 0); + /* Pad to the full width with 0. */ + while (cp != start) + *--cp = '0'; + } + break; + case 'l': + case 'Z': + if (p[1] == 'x') + { + unsigned long int num = va_arg (ap, unsigned long int); + char *start = wptr; + wptr += LONG_WIDTH / 4; + char *cp = _itoa (num, wptr, 16, 0); + /* Pad to the full width with 0. */ + while (cp != start) + *--cp = '0'; + ++p; + break; + } + /* FALLTHROUGH */ default: _dl_fatal_printf ("Fatal error:" " invalid format in exception string\n");