From patchwork Fri Jul 31 12:11:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 140330 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 355154B9DB4B for ; Fri, 31 Jul 2026 12:12:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 355154B9DB4B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=ZRIr0WCC X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 6D7044B1A378 for ; Fri, 31 Jul 2026 12:11:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D7044B1A378 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6D7044B1A378 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785499880; cv=none; b=L+tuLdHdJPRxKeqnxo1peYoTZ0NAXPjzlYFQikatev7cAwzwC5nMA/Tmt8JJDBAt4VgL3ISI0bWKp3mramKTbDcFt0T4/ZuYVvRXUIKhypefMKNaVhVDH4GSq25ILTTLWUiDTOcZFF5qa742HIH8IPbbbWOgDrk2LJmP6HwerLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785499880; c=relaxed/simple; bh=MMtQ9MSNzHYNPzRyqvB2L5H4m2Qcwwd3LqkcxtvHcrk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=RLZmB68QhY8888XYtiDz2VSqyPb3qwwT3VHPcmhODSp4QcDjK28y3FStuKlLXxXhT2yTQnI3pEWVThTnelJZe8E4GNpNG04w+BabMUrmWuQzbnLUWJ0chwnFpK1ZA60qNEZ+WxHrD+3UEPheQIiyrxfMqcHEqihs6fEBntkoB8w= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=ZRIr0WCC DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D7044B1A378 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-47f3b39f2a1so226269f8f.2 for ; Fri, 31 Jul 2026 05:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785499879; x=1786104679; darn=sourceware.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:to:from:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KC8pNtQJXR2RROBXDg5dmi/SSoL2v57Nc/53v/8rl4c=; b=ZRIr0WCCamD7q4s6RJpdVBVs41AsP25oic4aQLG2upIgdfR3+AhQqtUjnCuYiHR7rC Mqet3Xto1iRftnFj3cmg9C3hKJUhSmpMDwqbmJ3SjqIo81f6trORNKTqVoadyupuVmhf yw/UyDMbaN4ApOYireJl/RAsqstUREFUUkk56FBP2m//mN+oBg50zEC3zA6bgCGH9jDD a+aSwGdKZ11PealULH5DgoNA8HeDWlYpcYcbd126WA+eVsj/OidUxmTg24zIiLMBvgIp 0VTh/THmWQJGQbPJQfpxDuFTzhl0f4M3CgqXh2xEhUBdmWgnfiEHCIjRuFVRw2lOFXxA NR0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785499879; x=1786104679; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:to:from:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KC8pNtQJXR2RROBXDg5dmi/SSoL2v57Nc/53v/8rl4c=; b=OXWLjD41h7pbjK2iLLilUBAfJrGrSDzTfxUKOxI7RMSBMl0SkDv4RrwHargWCP+Aaf b7sLHrvbNuwvVjY7k+gVXZ756c15TdeQtkaMN+Pf4yRj0qbnpPmxrL07F4zfaY7iAq/8 mZBJL4IHb8r9FPxT3qf5+ALlx+2ls+2EtGIjsh8psSdcIcjeiLNIlU13FWkWm9Vf6yU2 IY1HX67EjVx2ZQHG324VJvOMDUChs/ilfYEIbmIRyWjQYS+UwLTmLeJaAwmRTBvvH9fN GPKklHhzR5atx8vbaFTzfD6W7OwOA3R01UfVFVoZlW4HgvnCkskn4b34cUbqmeeNWJyT xJ1A== X-Gm-Message-State: AOJu0YxxUopcjYIh95kQjL+orES+oLsMQD+YgVlx8Fm+ScXEo1xmodg7 WWddN1rdig3BxO73JiFKZZF9H0STJRfItE3Fu1ND4hZeG0ocISiGC3BUtQ8+EFyOwawyt9SaogW faZFoAw== X-Gm-Gg: AR+sD12yGZu6AiX/wkisKP3lqx0fAkaKMpmxIjj0fJXf9luRM3o0ODIhZzxhllXsaBA C4excwRRcZeQZuH8DJaI+SJHmZqhaAL0dXS2C12GSAvNqblDlPFvT857YBgEyLhLE59VgFYZGs9 uI+dQJh4e8vSuO0Lb1/lPcfxFK2DHR3RQHh2sNmQgihcBGa2bgOBwJc3B1lLQFT8BJjT7C8G7T1 xwm3Pqv0RPALZUT3DBZ2T5/St1j/olS+Z+9W8hsxfelalldrNddAVP0QNRXUJhYGFQeeDMI2X+I ht5O2Yb+bSoSL192aU410phhvHZ2ghY3vvllUs+lNLcRxQAUH9LDJRuq2Letk/r/4mpxYJfOe+m kj2nwCaZfaz/NtNTvwwcPKrlfzVIIPcjgXcphGZd3qaWrmjTqeKhD/B/w5Guxcb047peYGzd34F X+mViI7JNHDfx04D41TbQVlJ0HmdYs3/GmtJXsfxUMJwX9zfow4SqiWrdpQbZjrJZAMYWEKDB2w oPikL4t41RRWnmUCqClNn6sxZHCDhHzotirIiB6AWCr9Jhhb8M/BlltgQHua6M= X-Received: by 2002:a05:6000:1789:b0:47f:93d8:f480 with SMTP id ffacd0b85a97d-47fd2b4d714mr4341263f8f.39.1785499879235; Fri, 31 Jul 2026 05:11:19 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47fd456220esm4329558f8f.18.2026.07.31.05.11.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Jul 2026 05:11:18 -0700 (PDT) Message-ID: Date: Fri, 31 Jul 2026 14:11:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 3/5] readelf: fold get_{32,64}bit_elf_symbols() From: Jan Beulich To: Binutils References: <12e85879-b829-4652-9c87-473c0d8f296a@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <12e85879-b829-4652-9c87-473c0d8f296a@suse.com> X-Spam-Status: No, score=-3015.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org PR binutils/34356 They're identical except for the types used and the order of fields processed. The latter doesn't matter for correctness, and the former can be addressed by compiling the same code twice. --- v2: Use new file readelf-nn.c. --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -7871,250 +7871,14 @@ get_section_headers (Filedata *filedata, } static Elf_Internal_Sym * -get_32bit_elf_symbols (Filedata *filedata, - Elf_Internal_Shdr *section, - uint64_t *num_syms_return) -{ - uint64_t number = 0; - Elf32_External_Sym * esyms = NULL; - Elf_External_Sym_Shndx * shndx = NULL; - Elf_Internal_Sym * isyms = NULL; - Elf_Internal_Sym * psym; - unsigned int j; - elf_section_list * entry; - - if (section->sh_size == 0) - { - if (num_syms_return != NULL) - * num_syms_return = 0; - return NULL; - } - - /* Run some sanity checks first. */ - if (section->sh_entsize == 0 || section->sh_entsize > section->sh_size) - { - error (_("Section %s has an invalid sh_entsize of %#" PRIx64 "\n"), - printable_section_name (filedata, section), - section->sh_entsize); - goto exit_point; - } - - if (section->sh_size > filedata->file_size) - { - error (_("Section %s has an invalid sh_size of %#" PRIx64 "\n"), - printable_section_name (filedata, section), - section->sh_size); - goto exit_point; - } - - number = section->sh_size / section->sh_entsize; - - if (number * sizeof (Elf32_External_Sym) > section->sh_size + 1) - { - error (_("Size (%#" PRIx64 ") of section %s " - "is not a multiple of its sh_entsize (%#" PRIx64 ")\n"), - section->sh_size, - printable_section_name (filedata, section), - section->sh_entsize); - goto exit_point; - } - - esyms = (Elf32_External_Sym *) get_data (NULL, filedata, section->sh_offset, 1, - section->sh_size, _("symbols")); - if (esyms == NULL) - goto exit_point; - - shndx = NULL; - for (entry = filedata->symtab_shndx_list; entry != NULL; entry = entry->next) - { - if (entry->hdr->sh_link != (size_t) (section - filedata->section_headers)) - continue; - - if (shndx != NULL) - { - error (_("Multiple symbol table index sections associated with the same symbol section\n")); - free (shndx); - } - - shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata, - entry->hdr->sh_offset, - 1, entry->hdr->sh_size, - _("symbol table section indices")); - if (shndx == NULL) - goto exit_point; - - /* PR17531: file: heap-buffer-overflow */ - if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number) - { - error (_("Index section %s has an sh_size of %#" PRIx64 " - expected %#" PRIx64 "\n"), - printable_section_name (filedata, entry->hdr), - entry->hdr->sh_size, - section->sh_size); - goto exit_point; - } - } - - isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym)); - - if (isyms == NULL) - { - error (_("Out of memory reading %" PRIu64 " symbols\n"), number); - goto exit_point; - } - - for (j = 0, psym = isyms; j < number; j++, psym++) - { - psym->st_name = BYTE_GET (esyms[j].st_name); - psym->st_value = BYTE_GET (esyms[j].st_value); - psym->st_size = BYTE_GET (esyms[j].st_size); - psym->st_shndx = BYTE_GET (esyms[j].st_shndx); - if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL) - psym->st_shndx - = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); - else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff)) - psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff); - psym->st_info = BYTE_GET (esyms[j].st_info); - psym->st_other = BYTE_GET (esyms[j].st_other); - } - - exit_point: - free (shndx); - free (esyms); - - if (num_syms_return != NULL) - * num_syms_return = isyms == NULL ? 0 : number; - - return isyms; -} - -static Elf_Internal_Sym * -get_64bit_elf_symbols (Filedata *filedata, - Elf_Internal_Shdr *section, - uint64_t *num_syms_return) -{ - uint64_t number = 0; - Elf64_External_Sym * esyms = NULL; - Elf_External_Sym_Shndx * shndx = NULL; - Elf_Internal_Sym * isyms = NULL; - Elf_Internal_Sym * psym; - unsigned int j; - elf_section_list * entry; - - if (section->sh_size == 0) - { - if (num_syms_return != NULL) - * num_syms_return = 0; - return NULL; - } - - /* Run some sanity checks first. */ - if (section->sh_entsize == 0 || section->sh_entsize > section->sh_size) - { - error (_("Section %s has an invalid sh_entsize of %#" PRIx64 "\n"), - printable_section_name (filedata, section), - section->sh_entsize); - goto exit_point; - } - - if (section->sh_size > filedata->file_size) - { - error (_("Section %s has an invalid sh_size of %#" PRIx64 "\n"), - printable_section_name (filedata, section), - section->sh_size); - goto exit_point; - } - - number = section->sh_size / section->sh_entsize; - - if (number * sizeof (Elf64_External_Sym) > section->sh_size + 1) - { - error (_("Size (%#" PRIx64 ") of section %s " - "is not a multiple of its sh_entsize (%#" PRIx64 ")\n"), - section->sh_size, - printable_section_name (filedata, section), - section->sh_entsize); - goto exit_point; - } - - esyms = (Elf64_External_Sym *) get_data (NULL, filedata, section->sh_offset, 1, - section->sh_size, _("symbols")); - if (!esyms) - goto exit_point; - - shndx = NULL; - for (entry = filedata->symtab_shndx_list; entry != NULL; entry = entry->next) - { - if (entry->hdr->sh_link != (size_t) (section - filedata->section_headers)) - continue; - - if (shndx != NULL) - { - error (_("Multiple symbol table index sections associated with the same symbol section\n")); - free (shndx); - } - - shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata, - entry->hdr->sh_offset, - 1, entry->hdr->sh_size, - _("symbol table section indices")); - if (shndx == NULL) - goto exit_point; - - /* PR17531: file: heap-buffer-overflow */ - if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number) - { - error (_("Index section %s has an sh_size of %#" PRIx64 " - expected %#" PRIx64 "\n"), - printable_section_name (filedata, entry->hdr), - entry->hdr->sh_size, - section->sh_size); - goto exit_point; - } - } - - isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym)); - - if (isyms == NULL) - { - error (_("Out of memory reading %" PRIu64 " symbols\n"), number); - goto exit_point; - } - - for (j = 0, psym = isyms; j < number; j++, psym++) - { - psym->st_name = BYTE_GET (esyms[j].st_name); - psym->st_info = BYTE_GET (esyms[j].st_info); - psym->st_other = BYTE_GET (esyms[j].st_other); - psym->st_shndx = BYTE_GET (esyms[j].st_shndx); - - if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL) - psym->st_shndx - = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); - else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff)) - psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff); - - psym->st_value = BYTE_GET (esyms[j].st_value); - psym->st_size = BYTE_GET (esyms[j].st_size); - } - - exit_point: - free (shndx); - free (esyms); - - if (num_syms_return != NULL) - * num_syms_return = isyms == NULL ? 0 : number; - - return isyms; -} - -static Elf_Internal_Sym * get_elf_symbols (Filedata *filedata, Elf_Internal_Shdr *section, uint64_t *num_syms_return) { if (is_32bit_elf) - return get_32bit_elf_symbols (filedata, section, num_syms_return); + return Elf32_get_symbols (filedata, section, num_syms_return); else - return get_64bit_elf_symbols (filedata, section, num_syms_return); + return Elf64_get_symbols (filedata, section, num_syms_return); } static const char * --- a/binutils/readelf-nn.c +++ b/binutils/readelf-nn.c @@ -162,4 +162,122 @@ ElfXX(_get_section_headers) (Filedata * return true; } +static Elf_Internal_Sym * +ElfXX(_get_symbols) (Filedata *filedata, const Elf_Internal_Shdr *section, + uint64_t *num_syms_return) +{ + uint64_t number = 0; + ElfXX(_External_Sym) * esyms = NULL; + Elf_External_Sym_Shndx * shndx = NULL; + Elf_Internal_Sym * isyms = NULL; + Elf_Internal_Sym * psym; + unsigned int j; + elf_section_list * entry; + + if (section->sh_size == 0) + { + if (num_syms_return != NULL) + * num_syms_return = 0; + return NULL; + } + + /* Run some sanity checks first. */ + if (section->sh_entsize == 0 || section->sh_entsize > section->sh_size) + { + error (_("Section %s has an invalid sh_entsize of %#" PRIx64 "\n"), + printable_section_name (filedata, section), + section->sh_entsize); + goto exit_point; + } + + if (section->sh_size > filedata->file_size) + { + error (_("Section %s has an invalid sh_size of %#" PRIx64 "\n"), + printable_section_name (filedata, section), + section->sh_size); + goto exit_point; + } + + number = section->sh_size / section->sh_entsize; + + if (number * sizeof (*esyms) > section->sh_size + 1) + { + error (_("Size (%#" PRIx64 ") of section %s " + "is not a multiple of its sh_entsize (%#" PRIx64 ")\n"), + section->sh_size, + printable_section_name (filedata, section), + section->sh_entsize); + goto exit_point; + } + + esyms = get_data (NULL, filedata, section->sh_offset, 1, section->sh_size, + _("symbols")); + if (esyms == NULL) + goto exit_point; + + shndx = NULL; + for (entry = filedata->symtab_shndx_list; entry != NULL; entry = entry->next) + { + if (entry->hdr->sh_link != (size_t) (section - filedata->section_headers)) + continue; + + if (shndx != NULL) + { + error (_("Multiple symbol table index sections associated with the same symbol section\n")); + free (shndx); + } + + shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata, + entry->hdr->sh_offset, + 1, entry->hdr->sh_size, + _("symbol table section indices")); + if (shndx == NULL) + goto exit_point; + + /* PR17531: file: heap-buffer-overflow */ + if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number) + { + error (_("Index section %s has an sh_size of %#" PRIx64 " - expected %#" PRIx64 "\n"), + printable_section_name (filedata, entry->hdr), + entry->hdr->sh_size, + section->sh_size); + goto exit_point; + } + } + + isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym)); + + if (isyms == NULL) + { + error (_("Out of memory reading %" PRIu64 " symbols\n"), number); + goto exit_point; + } + + for (j = 0, psym = isyms; j < number; j++, psym++) + { + psym->st_name = BYTE_GET (esyms[j].st_name); + psym->st_value = BYTE_GET (esyms[j].st_value); + psym->st_size = BYTE_GET (esyms[j].st_size); + psym->st_shndx = BYTE_GET (esyms[j].st_shndx); + + if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL) + psym->st_shndx + = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); + else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff)) + psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff); + + psym->st_info = BYTE_GET (esyms[j].st_info); + psym->st_other = BYTE_GET (esyms[j].st_other); + } + + exit_point: + free (shndx); + free (esyms); + + if (num_syms_return != NULL) + * num_syms_return = isyms == NULL ? 0 : number; + + return isyms; +} + #undef ElfXX