From: Andrew C Aitchison Date: Tue, 9 Sep 2025 10:06:42 +0000 (+0200) Subject: Correct -Ue output for nm, objdump and readelf X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d67c8954d06292260bb70f95a566b9ba4ba632ef;p=thirdparty%2Fbinutils-gdb.git Correct -Ue output for nm, objdump and readelf ..., like PR33360 does for strings. Signed-off-by: Andrew C Aitchison --- diff --git a/binutils/nm.c b/binutils/nm.c index c3d118a93c3..4ea5c1190e7 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -566,8 +566,8 @@ display_utf8 (const unsigned char * in, char * out, unsigned int * consumed) case 4: out += sprintf (out, "\\u%02x%02x%02x", - ((in[0] & 0x07) << 6) | ((in[1] & 0x3c) >> 2), - ((in[1] & 0x03) << 6) | ((in[2] & 0x3c) >> 2), + ((in[0] & 0x07) << 2) | ((in[1] & 0x30) >> 4), + ((in[1] & 0x0f) << 4) | ((in[2] & 0x3c) >> 2), ((in[2] & 0x03) << 6) | ((in[3] & 0x3f))); break; default: diff --git a/binutils/objdump.c b/binutils/objdump.c index ee8823da05a..513f6162204 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -659,8 +659,8 @@ display_utf8 (const unsigned char * in, char * out, unsigned int * consumed) case 4: out += sprintf (out, "\\u%02x%02x%02x", - ((in[0] & 0x07) << 6) | ((in[1] & 0x3c) >> 2), - ((in[1] & 0x03) << 6) | ((in[2] & 0x3c) >> 2), + ((in[0] & 0x07) << 2) | ((in[1] & 0x30) >> 4), + ((in[1] & 0x0f) << 4) | ((in[2] & 0x3c) >> 2), ((in[2] & 0x03) << 6) | ((in[3] & 0x3f))); break; default: diff --git a/binutils/readelf.c b/binutils/readelf.c index 10f81779d09..8162cbb7003 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -848,8 +848,8 @@ print_symbol_name (signed int width, const char * symbol) if (width_remaining < 8) break; printf ("\\u%02x%02x%02x", - ((bytes[0] & 0x07) << 6) | ((bytes[1] & 0x3c) >> 2), - ((bytes[1] & 0x03) << 6) | ((bytes[2] & 0x3c) >> 2), + ((bytes[0] & 0x07) << 2) | ((bytes[1] & 0x30) >> 4), + ((bytes[1] & 0x0f) << 4) | ((bytes[2] & 0x3c) >> 2), ((bytes[2] & 0x03) << 6) | (bytes[3] & 0x3f)); break;