[v3,2/2] libgloss: pru: Trim crt0-minrt.o

Message ID 20240104171952.1409897-2-dimitar@dinux.eu
State New
Headers
Series [v3,1/2] libgloss: merge pru into top-level Makefile |

Commit Message

Dimitar Dimitrov Jan. 4, 2024, 5:19 p.m. UTC
  Strip a few more instructions from crt0-minrt.S:
  - Remove "halt" and rely on the infinite loop after main()'s return.
  - Remove main()'s argc and argv argument initialization.  Host loader
    does not set them, and typical firmware does not use them, either.
  - Remove the __dso_handle symbol.

This should be safe because the default crt0.S is fully standards
compliant.  Whereas crt0-minrt.S has been documented from the beginning
to intentionally miss features in order to reduce firmware size, while
still enabling typical PRU firmware to operate.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
---
 libgloss/pru/crt0-minrt.S | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
  

Comments

Dimitar Dimitrov Jan. 20, 2024, 7:01 a.m. UTC | #1
On Thu, Jan 04, 2024 at 07:19:52PM +0200, Dimitar Dimitrov wrote:
> Strip a few more instructions from crt0-minrt.S:
>   - Remove "halt" and rely on the infinite loop after main()'s return.
>   - Remove main()'s argc and argv argument initialization.  Host loader
>     does not set them, and typical firmware does not use them, either.
>   - Remove the __dso_handle symbol.
> 
> This should be safe because the default crt0.S is fully standards
> compliant.  Whereas crt0-minrt.S has been documented from the beginning
> to intentionally miss features in order to reduce firmware size, while
> still enabling typical PRU firmware to operate.
> 
> Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
> ---
>  libgloss/pru/crt0-minrt.S | 15 +--------------
>  1 file changed, 1 insertion(+), 14 deletions(-)

Ping.

Regards,
Dimitar
  
Mike Frysinger Jan. 20, 2024, 1:46 p.m. UTC | #2
should you be listed in newlib/MAINTAINERS for pru ?
-mike
  
Dimitar Dimitrov Jan. 20, 2024, 3:15 p.m. UTC | #3
On Sat, Jan 20, 2024 at 08:46:36AM -0500, Mike Frysinger wrote:
> should you be listed in newlib/MAINTAINERS for pru ?
> -mike

Yes, I would be honoured.

I've been running and monitoring CI for the GNU toolchain for PRU,
including newlib, for a few years.  And I intend to continue doing so.

Thanks,
Dimitar
  
Mike Frysinger Jan. 20, 2024, 6:57 p.m. UTC | #4
On 20 Jan 2024 17:15, Dimitar Dimitrov wrote:
> On Sat, Jan 20, 2024 at 08:46:36AM -0500, Mike Frysinger wrote:
> > should you be listed in newlib/MAINTAINERS for pru ?
> 
> Yes, I would be honoured.
> 
> I've been running and monitoring CI for the GNU toolchain for PRU,
> including newlib, for a few years.  And I intend to continue doing so.

send a patch for Corinna & Jeff to approve :)

do you have push access to newlib now ?  might be worth asking for that too
so you can be added to the "write privileges after getting approval" section.
-mike
  
Corinna Vinschen Jan. 22, 2024, 10:04 a.m. UTC | #5
On Jan 20 13:57, Mike Frysinger wrote:
> On 20 Jan 2024 17:15, Dimitar Dimitrov wrote:
> > On Sat, Jan 20, 2024 at 08:46:36AM -0500, Mike Frysinger wrote:
> > > should you be listed in newlib/MAINTAINERS for pru ?
> > 
> > Yes, I would be honoured.
> > 
> > I've been running and monitoring CI for the GNU toolchain for PRU,
> > including newlib, for a few years.  And I intend to continue doing so.
> 
> send a patch for Corinna & Jeff to approve :)
> 
> do you have push access to newlib now ?  might be worth asking for that too
> so you can be added to the "write privileges after getting approval" section.
> -mike

libgloss isn't my playfield, so I was deferring this to Jeff.
Personally I have no problems with that.

For the time being, I was trying to merge the patches but the
first patch to the build system already fails to apply cleanly.
ANy chance to regenerate it relative to current main?


Thanks,
Corinna
  
Mike Frysinger Jan. 22, 2024, 5:27 p.m. UTC | #6
On 22 Jan 2024 11:04, Corinna Vinschen wrote:
> On Jan 20 13:57, Mike Frysinger wrote:
> > On 20 Jan 2024 17:15, Dimitar Dimitrov wrote:
> > > On Sat, Jan 20, 2024 at 08:46:36AM -0500, Mike Frysinger wrote:
> > > > should you be listed in newlib/MAINTAINERS for pru ?
> > > 
> > > Yes, I would be honoured.
> > > 
> > > I've been running and monitoring CI for the GNU toolchain for PRU,
> > > including newlib, for a few years.  And I intend to continue doing so.
> > 
> > send a patch for Corinna & Jeff to approve :)
> > 
> > do you have push access to newlib now ?  might be worth asking for that too
> > so you can be added to the "write privileges after getting approval" section.
> 
> libgloss isn't my playfield, so I was deferring this to Jeff.

any value in carving out a more specific libgloss/MAINTAINERS ?
i'd be happy to be a "global" maintainer there ... just not in newlib :).
-mike
  
Jeff Johnston Jan. 22, 2024, 6:57 p.m. UTC | #7
On Mon, Jan 22, 2024 at 5:04 AM Corinna Vinschen <vinschen@redhat.com>
wrote:

> On Jan 20 13:57, Mike Frysinger wrote:
> > On 20 Jan 2024 17:15, Dimitar Dimitrov wrote:
> > > On Sat, Jan 20, 2024 at 08:46:36AM -0500, Mike Frysinger wrote:
> > > > should you be listed in newlib/MAINTAINERS for pru ?
> > >
> > > Yes, I would be honoured.
> > >
> > > I've been running and monitoring CI for the GNU toolchain for PRU,
> > > including newlib, for a few years.  And I intend to continue doing so.
> >
> > send a patch for Corinna & Jeff to approve :)
> >
> > do you have push access to newlib now ?  might be worth asking for that
> too
> > so you can be added to the "write privileges after getting approval"
> section.
> > -mike
>
> libgloss isn't my playfield, so I was deferring this to Jeff.
> Personally I have no problems with that.
>

I'm fine too.  I'll add Dimitar for pru to newlib/MAINTAINERS file.  I
don't offhand know the process for
getting push access to newlib.


> For the time being, I was trying to merge the patches but the
> first patch to the build system already fails to apply cleanly.
> ANy chance to regenerate it relative to current main?
>
>
> Thanks,
> Corinna
>
>
  
Corinna Vinschen Jan. 23, 2024, 9:04 a.m. UTC | #8
On Jan 22 12:27, Mike Frysinger wrote:
> On 22 Jan 2024 11:04, Corinna Vinschen wrote:
> > On Jan 20 13:57, Mike Frysinger wrote:
> > > On 20 Jan 2024 17:15, Dimitar Dimitrov wrote:
> > > > On Sat, Jan 20, 2024 at 08:46:36AM -0500, Mike Frysinger wrote:
> > > > > should you be listed in newlib/MAINTAINERS for pru ?
> > > > 
> > > > Yes, I would be honoured.
> > > > 
> > > > I've been running and monitoring CI for the GNU toolchain for PRU,
> > > > including newlib, for a few years.  And I intend to continue doing so.
> > > 
> > > send a patch for Corinna & Jeff to approve :)
> > > 
> > > do you have push access to newlib now ?  might be worth asking for that too
> > > so you can be added to the "write privileges after getting approval" section.
> > 
> > libgloss isn't my playfield, so I was deferring this to Jeff.
> 
> any value in carving out a more specific libgloss/MAINTAINERS ?
> i'd be happy to be a "global" maintainer there ... just not in newlib :).

That sounds really good to me.  Jeff?


Corinna
  
Jeff Johnston Jan. 23, 2024, 3:55 p.m. UTC | #9
On Tue, Jan 23, 2024 at 4:04 AM Corinna Vinschen <vinschen@redhat.com>
wrote:

> On Jan 22 12:27, Mike Frysinger wrote:
> > On 22 Jan 2024 11:04, Corinna Vinschen wrote:
> > > On Jan 20 13:57, Mike Frysinger wrote:
> > > > On 20 Jan 2024 17:15, Dimitar Dimitrov wrote:
> > > > > On Sat, Jan 20, 2024 at 08:46:36AM -0500, Mike Frysinger wrote:
> > > > > > should you be listed in newlib/MAINTAINERS for pru ?
> > > > >
> > > > > Yes, I would be honoured.
> > > > >
> > > > > I've been running and monitoring CI for the GNU toolchain for PRU,
> > > > > including newlib, for a few years.  And I intend to continue doing
> so.
> > > >
> > > > send a patch for Corinna & Jeff to approve :)
> > > >
> > > > do you have push access to newlib now ?  might be worth asking for
> that too
> > > > so you can be added to the "write privileges after getting approval"
> section.
> > >
> > > libgloss isn't my playfield, so I was deferring this to Jeff.
> >
> > any value in carving out a more specific libgloss/MAINTAINERS ?
> > i'd be happy to be a "global" maintainer there ... just not in newlib :).
>
> That sounds really good to me.  Jeff?
>
>
I agree.

-- Jeff J.



> Corinna
>
>
  

Patch

diff --git a/libgloss/pru/crt0-minrt.S b/libgloss/pru/crt0-minrt.S
index 60647d372..fa5e80af4 100644
--- a/libgloss/pru/crt0-minrt.S
+++ b/libgloss/pru/crt0-minrt.S
@@ -38,22 +38,9 @@  _start:
 
 	/* DATA and BSS are handled by the loader, so nothing to do here. */
 
-	/* Just in case main() tries to access argc, argv[] and envp. */
-	zero	r14, 3 * 4
-
-	/* Call main. */
+	/* Call main. Assume argc and argv are not used with -minrt! */
 	call	main
 
 	/* We should never reach here. */
 _crt_exit:
-	halt
 	jmp	_crt_exit
-
-	/* PRU obviously has no shared libraries, but dso_handle
-	   helps to achieve better GCC test coverage. Besides,
-	   it should be free with minrt. */
-	.section .data
-	.global __dso_handle
-	.weak __dso_handle
-__dso_handle:
-	.long	0