[v2] Set the sh_entsize field of .stab to 12

Message ID 20200403060346.237913-1-maskray@google.com
State New
Headers show
Series
  • [v2] Set the sh_entsize field of .stab to 12
Related show

Commit Message

H.J. Lu via Binutils April 3, 2020, 6:03 a.m.
The existing code assumes sh_entsize(.stab)=20 on ELFCLASS64.
However, the assembler only supports 32-bit stabs. So set sh_entsize unconditionally to 12.

	PR gas/25768
	* elf.c (assign_section_numbers): Set .stab sh_entsize to 12.
---
 bfd/ChangeLog | 5 +++++
 bfd/elf.c     | 4 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

-- 
2.26.0.292.g33ef6b2f38-goog

Comments

H.J. Lu via Binutils April 8, 2020, 10 p.m. | #1
On 2020-04-02, Fangrui Song wrote:
>The existing code assumes sh_entsize(.stab)=20 on ELFCLASS64.

>However, the assembler only supports 32-bit stabs. So set sh_entsize unconditionally to 12.

>

>	PR gas/25768

>	* elf.c (assign_section_numbers): Set .stab sh_entsize to 12.

>---

> bfd/ChangeLog | 5 +++++

> bfd/elf.c     | 4 +---

> 2 files changed, 6 insertions(+), 3 deletions(-)

>

>diff --git a/bfd/ChangeLog b/bfd/ChangeLog

>index 64c3dde475..47b8e566ef 100644

>--- a/bfd/ChangeLog

>+++ b/bfd/ChangeLog

>@@ -1,3 +1,8 @@

>+2020-04-02  Fangrui Song  <maskray@google.com>

>+

>+	PR gas/25768

>+	* elf.c (assign_section_numbers): Set .stab sh_entsize to 12.

>+

> 2020-04-02  Jan W. Jagersma  <jwjagersma@gmail.com>

>

> 	* bfdio.c (bfd_bread, bfd_tell, bfd_seek, bfd_mmap): Always add

>diff --git a/bfd/elf.c b/bfd/elf.c

>index 86dadea05c..0c550bdadf 100644

>--- a/bfd/elf.c

>+++ b/bfd/elf.c

>@@ -3998,9 +3998,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)

> 		  elf_section_data (s)->this_hdr.sh_link = d->this_idx;

>

> 		  /* This is a .stab section.  */

>-		  if (elf_section_data (s)->this_hdr.sh_entsize == 0)

>-		    elf_section_data (s)->this_hdr.sh_entsize

>-		      = 4 + 2 * bfd_get_arch_size (abfd) / 8;

>+		  elf_section_data (s)->this_hdr.sh_entsize = 12;

> 		}

> 	    }

> 	  break;

>-- 

>2.26.0.292.g33ef6b2f38-goog

>

Ping :)
H.J. Lu via Binutils April 9, 2020, 10:24 a.m. | #2
Hi Fangrui,

>>     PR gas/25768

>>     * elf.c (assign_section_numbers): Set .stab sh_entsize to 12.


Approved - please apply.

> Ping :)


Sorry - I blame the weather - or aliens - or anything but my own laziness.

Cheers
  Nick
H.J. Lu via Binutils April 9, 2020, 3:37 p.m. | #3
On 2020-04-09, Nick Clifton wrote:
>Hi Fangrui,

>

>>>     PR gas/25768

>>>     * elf.c (assign_section_numbers): Set .stab sh_entsize to 12.

>

>Approved - please apply.

>

>> Ping :)

>

>Sorry - I blame the weather - or aliens - or anything but my own laziness.

>

>Cheers

>  Nick


No worries! Nick, can you apply it on my behalf? I don't have a commit bit.
H.J. Lu via Binutils April 14, 2020, 2:23 p.m. | #4
Hi Fangrui,

>>>>     PR gas/25768

>>>>     * elf.c (assign_section_numbers): Set .stab sh_entsize to 12.

>>

>> Approved - please apply.


> No worries! Nick, can you apply it on my behalf? I don't have a commit bit.


Applied.

Cheers
  Nick

Patch

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 64c3dde475..47b8e566ef 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@ 
+2020-04-02  Fangrui Song  <maskray@google.com>
+
+	PR gas/25768
+	* elf.c (assign_section_numbers): Set .stab sh_entsize to 12.
+
 2020-04-02  Jan W. Jagersma  <jwjagersma@gmail.com>
 
 	* bfdio.c (bfd_bread, bfd_tell, bfd_seek, bfd_mmap): Always add
diff --git a/bfd/elf.c b/bfd/elf.c
index 86dadea05c..0c550bdadf 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3998,9 +3998,7 @@  assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
 		  elf_section_data (s)->this_hdr.sh_link = d->this_idx;
 
 		  /* This is a .stab section.  */
-		  if (elf_section_data (s)->this_hdr.sh_entsize == 0)
-		    elf_section_data (s)->this_hdr.sh_entsize
-		      = 4 + 2 * bfd_get_arch_size (abfd) / 8;
+		  elf_section_data (s)->this_hdr.sh_entsize = 12;
 		}
 	    }
 	  break;