public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ld: pru: Fix resource_table output section alignment
@ 2021-09-28 19:35 Dimitar Dimitrov
  2021-09-30  4:49 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Dimitar Dimitrov @ 2021-09-28 19:35 UTC (permalink / raw)
  To: binutils

My commit 261980de18b added alignment for the resource table symbol.
But it is wrong.  The Linux remoteproc driver loads and interprets the
contents of the .resource_table ELF section, not of a table symbol.

Without this patch, if the linker happens to output padding for symbol
alignment, then the resource table contents as viewed by the kernel
loader would "shift" and look corrupted.

I kindly ask this fix to be picked for both trunk and the 2.37 branch.

ld/ChangeLog:

	* scripttempl/pru.sc  (.resource_table): Align the output
	section, not the first symbol.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
---
 ld/scripttempl/pru.sc | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/ld/scripttempl/pru.sc b/ld/scripttempl/pru.sc
index b2c941b7911..97d8be0a0a4 100644
--- a/ld/scripttempl/pru.sc
+++ b/ld/scripttempl/pru.sc
@@ -151,11 +151,10 @@ SECTIONS
     ${RELOCATING+ PROVIDE (_data_end = .) ; }
   } ${RELOCATING+ > dmem }
 
-  .resource_table ${RELOCATING-0} :
+  /* Linux remoteproc loader requires the resource_table section
+     start address to be aligned to 8 bytes.  */
+  .resource_table ${RELOCATING-0} ${RELOCATING+ ALIGN(8)} :
   {
-    /* Linux remoteproc loader requires the resource table address
-       to be aligned to 8 bytes.  */
-    ${RELOCATING+. = ALIGN(8);}
     KEEP (*(.resource_table))
   } ${RELOCATING+ > dmem}
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ld: pru: Fix resource_table output section alignment
  2021-09-28 19:35 [PATCH] ld: pru: Fix resource_table output section alignment Dimitar Dimitrov
@ 2021-09-30  4:49 ` Alan Modra
  2021-09-30 19:27   ` Dimitar Dimitrov
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2021-09-30  4:49 UTC (permalink / raw)
  To: Dimitar Dimitrov; +Cc: binutils

On Tue, Sep 28, 2021 at 10:35:44PM +0300, Dimitar Dimitrov wrote:
> My commit 261980de18b added alignment for the resource table symbol.
> But it is wrong.  The Linux remoteproc driver loads and interprets the
> contents of the .resource_table ELF section, not of a table symbol.
> 
> Without this patch, if the linker happens to output padding for symbol
> alignment, then the resource table contents as viewed by the kernel
> loader would "shift" and look corrupted.
> 
> I kindly ask this fix to be picked for both trunk and the 2.37 branch.
> 
> ld/ChangeLog:
> 
> 	* scripttempl/pru.sc  (.resource_table): Align the output
> 	section, not the first symbol.

This is OK.  I assume you can commit the patch since I see you have
commits to sim/.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ld: pru: Fix resource_table output section alignment
  2021-09-30  4:49 ` Alan Modra
@ 2021-09-30 19:27   ` Dimitar Dimitrov
  0 siblings, 0 replies; 3+ messages in thread
From: Dimitar Dimitrov @ 2021-09-30 19:27 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

On Thu, Sep 30, 2021 at 02:19:10PM +0930, Alan Modra wrote:
> On Tue, Sep 28, 2021 at 10:35:44PM +0300, Dimitar Dimitrov wrote:
> > My commit 261980de18b added alignment for the resource table symbol.
> > But it is wrong.  The Linux remoteproc driver loads and interprets the
> > contents of the .resource_table ELF section, not of a table symbol.
> > 
> > Without this patch, if the linker happens to output padding for symbol
> > alignment, then the resource table contents as viewed by the kernel
> > loader would "shift" and look corrupted.
> > 
> > I kindly ask this fix to be picked for both trunk and the 2.37 branch.
> > 
> > ld/ChangeLog:
> > 
> > 	* scripttempl/pru.sc  (.resource_table): Align the output
> > 	section, not the first symbol.
> 
> This is OK.  I assume you can commit the patch since I see you have
> commits to sim/.
Thank you. I pushed to both 2.37 (a9c3934f6cb) and master (5109a7bd9b8).

Regards,
Dimitar

> 
> -- 
> Alan Modra
> Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-30 19:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 19:35 [PATCH] ld: pru: Fix resource_table output section alignment Dimitar Dimitrov
2021-09-30  4:49 ` Alan Modra
2021-09-30 19:27   ` Dimitar Dimitrov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).