aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-15 09:42:44 +0930
committerAlan Modra <amodra@gmail.com>2020-08-15 14:16:02 +0930
commit4d1823674eedf267c7cafac2b923256db0b10ac8 (patch)
treef9c342023c7521c374baebe719774048d95a2895 /bfd
parenta9ca57d09a0b7bffb583e42b8b49541727ce676b (diff)
downloadfsf-binutils-gdb-4d1823674eedf267c7cafac2b923256db0b10ac8.zip
fsf-binutils-gdb-4d1823674eedf267c7cafac2b923256db0b10ac8.tar.gz
fsf-binutils-gdb-4d1823674eedf267c7cafac2b923256db0b10ac8.tar.bz2
PR26389, nm prints "c" for a common symbol with -flto and -fcommon
git commit 49d9fd42acef chose to make nm print 'C' for the normal common section, and 'c' for other commons. This was an attempt to make common symbols in .scommon and other small common sections show a 'c' type without a section name comparison, but it failed for nm --plugin on lto objects where normal common symbols are stashed in a "plug" section. It's also wrong for large common symbols. So instead set SEC_SMALL_DATA on sections created for small commons, and key off that flag to show 'c' type. If your ELF target doesn't have an elf_backend_symbol_processing function, then you won't see 'c' for symbols in .scommon. Note that due to bfd_decode_symclass decoding common symbols without a chance for coff_section_type to treat .scommon specially, then having .scommon in the array of special sections handled by coff_section_type prior to 49d9fd42acef was entirely ineffective. That fact escaped me when writing 49d9fd42acef. Unless .scommon didn't have SEC_IS_COMMON set, which would be a little weird. PR 26389 * syms.c (bfd_decode_symclass): Choose 'c' for commons only when SEC_SMALL_DATA. * elf32-m32r.c (_bfd_m32r_elf_symbol_processing): Set SEC_SMALL_DATA on small common section. * elf32-score.c (s3_bfd_score_elf_symbol_processing): Likewise. * elf32-score7.c (s7_bfd_score_elf_symbol_processing): Likewise. * elf32-tic6x.c (elf32_tic6x_symbol_processing): Likewise. * elf32-v850.c (v850_elf_symbol_processing): Likewise. * elfxx-mips.c (_bfd_mips_elf_symbol_processing): Likewise. * ecoff.c (ecoff_set_symbol_info, ecoff_link_add_externals): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog14
-rw-r--r--bfd/ecoff.c4
-rw-r--r--bfd/elf32-m32r.c2
-rw-r--r--bfd/elf32-score.c2
-rw-r--r--bfd/elf32-score7.c2
-rw-r--r--bfd/elf32-tic6x.c2
-rw-r--r--bfd/elf32-v850.c7
-rw-r--r--bfd/elfxx-mips.c2
-rw-r--r--bfd/syms.c6
9 files changed, 28 insertions, 13 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ef077c4..85fb618 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,17 @@
+2020-08-15 Alan Modra <amodra@gmail.com>
+
+ PR 26389
+ * syms.c (bfd_decode_symclass): Choose 'c' for commons only when
+ SEC_SMALL_DATA.
+ * elf32-m32r.c (_bfd_m32r_elf_symbol_processing): Set SEC_SMALL_DATA
+ on small common section.
+ * elf32-score.c (s3_bfd_score_elf_symbol_processing): Likewise.
+ * elf32-score7.c (s7_bfd_score_elf_symbol_processing): Likewise.
+ * elf32-tic6x.c (elf32_tic6x_symbol_processing): Likewise.
+ * elf32-v850.c (v850_elf_symbol_processing): Likewise.
+ * elfxx-mips.c (_bfd_mips_elf_symbol_processing): Likewise.
+ * ecoff.c (ecoff_set_symbol_info, ecoff_link_add_externals): Likewise.
+
2020-08-14 Alan Modra <amodra@gmail.com>
* hash.c (bfd_hash_set_default_size): Use higher_prime_number
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index dcded6f..2e4bf88 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -791,7 +791,7 @@ ecoff_set_symbol_info (bfd *abfd,
{
/* Initialize the small common section. */
ecoff_scom_section.name = SCOMMON;
- ecoff_scom_section.flags = SEC_IS_COMMON;
+ ecoff_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
ecoff_scom_section.output_section = &ecoff_scom_section;
ecoff_scom_section.symbol = &ecoff_scom_symbol;
ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
@@ -3404,7 +3404,7 @@ ecoff_link_add_externals (bfd *abfd,
{
/* Initialize the small common section. */
ecoff_scom_section.name = SCOMMON;
- ecoff_scom_section.flags = SEC_IS_COMMON;
+ ecoff_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
ecoff_scom_section.output_section = &ecoff_scom_section;
ecoff_scom_section.symbol = &ecoff_scom_symbol;
ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 2eae00b..ea8e337 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -1354,7 +1354,7 @@ _bfd_m32r_elf_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym)
{
/* Initialize the small common section. */
m32r_elf_scom_section.name = ".scommon";
- m32r_elf_scom_section.flags = SEC_IS_COMMON;
+ m32r_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
m32r_elf_scom_section.output_section = &m32r_elf_scom_section;
m32r_elf_scom_section.symbol = &m32r_elf_scom_symbol;
m32r_elf_scom_section.symbol_ptr_ptr = &m32r_elf_scom_symbol_ptr;
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index d1a910f..4be6561 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -3035,7 +3035,7 @@ s3_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
{
/* Initialize the small common section. */
score_elf_scom_section.name = ".scommon";
- score_elf_scom_section.flags = SEC_IS_COMMON;
+ score_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
score_elf_scom_section.output_section = &score_elf_scom_section;
score_elf_scom_section.symbol = &score_elf_scom_symbol;
score_elf_scom_section.symbol_ptr_ptr = &score_elf_scom_symbol_ptr;
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index ab5e32a..c974690 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -2840,7 +2840,7 @@ s7_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
{
/* Initialize the small common section. */
score_elf_scom_section.name = ".scommon";
- score_elf_scom_section.flags = SEC_IS_COMMON;
+ score_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
score_elf_scom_section.output_section = &score_elf_scom_section;
score_elf_scom_section.symbol = &score_elf_scom_symbol;
score_elf_scom_section.symbol_ptr_ptr = &score_elf_scom_symbol_ptr;
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index 9984c05..a37ae29 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -2974,7 +2974,7 @@ elf32_tic6x_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym)
{
/* Initialize the small common section. */
tic6x_elf_scom_section.name = ".scommon";
- tic6x_elf_scom_section.flags = SEC_IS_COMMON;
+ tic6x_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
tic6x_elf_scom_section.output_section = &tic6x_elf_scom_section;
tic6x_elf_scom_section.symbol = &tic6x_elf_scom_symbol;
tic6x_elf_scom_section.symbol_ptr_ptr = &tic6x_elf_scom_symbol_ptr;
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 0235044..c1e959e 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -3001,7 +3001,8 @@ v850_elf_symbol_processing (bfd *abfd, asymbol *asym)
{
/* Initialize the small common section. */
v850_elf_scom_section.name = ".scommon";
- v850_elf_scom_section.flags = SEC_IS_COMMON | SEC_ALLOC | SEC_DATA;
+ v850_elf_scom_section.flags
+ = SEC_IS_COMMON | SEC_SMALL_DATA | SEC_ALLOC | SEC_DATA;
v850_elf_scom_section.output_section = & v850_elf_scom_section;
v850_elf_scom_section.symbol = & v850_elf_scom_symbol;
v850_elf_scom_section.symbol_ptr_ptr = & v850_elf_scom_symbol_ptr;
@@ -3019,7 +3020,7 @@ v850_elf_symbol_processing (bfd *abfd, asymbol *asym)
{
/* Initialize the tcommon section. */
v850_elf_tcom_section.name = ".tcommon";
- v850_elf_tcom_section.flags = SEC_IS_COMMON;
+ v850_elf_tcom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
v850_elf_tcom_section.output_section = & v850_elf_tcom_section;
v850_elf_tcom_section.symbol = & v850_elf_tcom_symbol;
v850_elf_tcom_section.symbol_ptr_ptr = & v850_elf_tcom_symbol_ptr;
@@ -3037,7 +3038,7 @@ v850_elf_symbol_processing (bfd *abfd, asymbol *asym)
{
/* Initialize the zcommon section. */
v850_elf_zcom_section.name = ".zcommon";
- v850_elf_zcom_section.flags = SEC_IS_COMMON;
+ v850_elf_zcom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
v850_elf_zcom_section.output_section = & v850_elf_zcom_section;
v850_elf_zcom_section.symbol = & v850_elf_zcom_symbol;
v850_elf_zcom_section.symbol_ptr_ptr = & v850_elf_zcom_symbol_ptr;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 7cfce13..5b985a4 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -7113,7 +7113,7 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym)
{
/* Initialize the small common section. */
mips_elf_scom_section.name = ".scommon";
- mips_elf_scom_section.flags = SEC_IS_COMMON;
+ mips_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
mips_elf_scom_section.output_section = &mips_elf_scom_section;
mips_elf_scom_section.symbol = &mips_elf_scom_symbol;
mips_elf_scom_section.symbol_ptr_ptr = &mips_elf_scom_symbol_ptr;
diff --git a/bfd/syms.c b/bfd/syms.c
index b9f7336..cb25af1 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -653,10 +653,10 @@ bfd_decode_symclass (asymbol *symbol)
if (symbol->section && bfd_is_com_section (symbol->section))
{
- if (symbol->section == bfd_com_section_ptr)
- return 'C';
- else
+ if (symbol->section->flags & SEC_SMALL_DATA)
return 'c';
+ else
+ return 'C';
}
if (bfd_is_und_section (symbol->section))
{