diff mbox series

netbsd EABI support

Message ID 20190408151754.GA7666@SDF.ORG
State New
Headers show
Series netbsd EABI support | expand

Commit Message

Maya Rashish April 8, 2019, 3:17 p.m. UTC
Pinging again in the hope of getting the patch in, I'd like to have
less outstanding patches :) (I have quite a few and new releases
can become painful!)

gcc/ChangeLog

config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
config.host (arm*-*-netbsd*): Build driver-arm.o
config/arm/netbsd-eabi.h: New file.
config/arm/netbsd-elf.h
config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.

libgcc/ChangeLog

config.host (arm*-*-netbsdelf*): Add support for EABI configuration
config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
		     HOST_LIBGCC2_CFLAGS: workaround possible bug
config/arm/t-netbsd-eabi: New file.

---
 gcc/config.gcc                  | 29 +++++++++-
 gcc/config.host                 |  2 +-
 gcc/config/arm/netbsd-eabi.h    | 97 +++++++++++++++++++++++++++++++++
 gcc/config/arm/netbsd-elf.h     | 10 ++++
 gcc/config/netbsd-elf.h         | 15 +++++
 libgcc/config.host              | 10 +++-
 libgcc/config/arm/t-netbsd      | 10 +++-
 libgcc/config/arm/t-netbsd-eabi | 18 ++++++
 8 files changed, 184 insertions(+), 7 deletions(-)
 create mode 100644 gcc/config/arm/netbsd-eabi.h
 create mode 100644 libgcc/config/arm/t-netbsd-eabi

Comments

Jeff Law April 9, 2019, 3:04 p.m. UTC | #1
On 4/8/19 9:17 AM, coypu@sdf.org wrote:
> Pinging again in the hope of getting the patch in, I'd like to have
> less outstanding patches :) (I have quite a few and new releases
> can become painful!)
> 
> gcc/ChangeLog
> 
> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
> config.host (arm*-*-netbsd*): Build driver-arm.o
> config/arm/netbsd-eabi.h: New file.
> config/arm/netbsd-elf.h
> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
> 
> libgcc/ChangeLog
> 
> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
> 		     HOST_LIBGCC2_CFLAGS: workaround possible bug
> config/arm/t-netbsd-eabi: New file.
So we're well into stage4 which means technically it's too late for
something like this.  However, given it's limited scope I won't object
if the ARM port maintainers want to go forward.  Otherwise I'll queue it
for gcc-10.

jeff
Richard Earnshaw (lists) April 9, 2019, 4:36 p.m. UTC | #2
On 09/04/2019 16:04, Jeff Law wrote:
> On 4/8/19 9:17 AM, coypu@sdf.org wrote:
>> Pinging again in the hope of getting the patch in, I'd like to have
>> less outstanding patches :) (I have quite a few and new releases
>> can become painful!)
>>
>> gcc/ChangeLog
>>
>> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
>> config.host (arm*-*-netbsd*): Build driver-arm.o
>> config/arm/netbsd-eabi.h: New file.
>> config/arm/netbsd-elf.h
>> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
>>
>> libgcc/ChangeLog
>>
>> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
>> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
>> 		     HOST_LIBGCC2_CFLAGS: workaround possible bug
>> config/arm/t-netbsd-eabi: New file.
> So we're well into stage4 which means technically it's too late for
> something like this.  However, given it's limited scope I won't object
> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
> for gcc-10.
> 
> jeff
> 

I was about to approve this (modulo removing the now obsolete
FPU_DEFAULT macro), until I noticed that it also modifies the generic
NetBSD code as well.  I'm certainly not willing to approve that myself
at this late stage, but if one of the NetBSD OS maintainers wants to
step up and do so, I'll happily take the Arm back-end code as that's not
a primary or secondary target.

R.
Maya Rashish May 9, 2019, 11:33 p.m. UTC | #3
On Tue, Apr 09, 2019 at 05:36:47PM +0100, Richard Earnshaw (lists) wrote:
> > So we're well into stage4 which means technically it's too late for
> > something like this.  However, given it's limited scope I won't object
> > if the ARM port maintainers want to go forward.  Otherwise I'll queue it
> > for gcc-10.
> > 
> > jeff
> > 
> 
> I was about to approve this (modulo removing the now obsolete
> FPU_DEFAULT macro), until I noticed that it also modifies the generic
> NetBSD code as well.  I'm certainly not willing to approve that myself
> at this late stage, but if one of the NetBSD OS maintainers wants to
> step up and do so, I'll happily take the Arm back-end code as that's not
> a primary or secondary target.
> 
> R.

Congrats on a new release :-)
ping
Richard Earnshaw (lists) May 10, 2019, 10:44 a.m. UTC | #4
On 10/05/2019 00:33, coypu@sdf.org wrote:
> On Tue, Apr 09, 2019 at 05:36:47PM +0100, Richard Earnshaw (lists) wrote:
>>> So we're well into stage4 which means technically it's too late for
>>> something like this.  However, given it's limited scope I won't object
>>> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
>>> for gcc-10.
>>>
>>> jeff
>>>
>>
>> I was about to approve this (modulo removing the now obsolete
>> FPU_DEFAULT macro), until I noticed that it also modifies the generic
>> NetBSD code as well.  I'm certainly not willing to approve that myself
>> at this late stage, but if one of the NetBSD OS maintainers wants to
>> step up and do so, I'll happily take the Arm back-end code as that's not
>> a primary or secondary target.
>>
>> R.
> 
> Congrats on a new release :-)
> ping
> 

I was hoping to get a comment from one of the netbsd port maintainers on
the changes to the common NetBSD code.  Are they no-longer active?

R.
Maya Rashish May 10, 2019, 2:24 p.m. UTC | #5
On Fri, May 10, 2019 at 11:44:28AM +0100, Richard Earnshaw (lists) wrote:
> I was hoping to get a comment from one of the netbsd port maintainers on
> the changes to the common NetBSD code.  Are they no-longer active?

Jason Thorpe said he can't contribute to GCC because of where he works.
Krister Walfridsson is slow to respond but does eventually and knows a
lot about GCC.
Jeff Law May 20, 2019, 7:24 p.m. UTC | #6
On 4/9/19 10:36 AM, Richard Earnshaw (lists) wrote:
> On 09/04/2019 16:04, Jeff Law wrote:
>> On 4/8/19 9:17 AM, coypu@sdf.org wrote:
>>> Pinging again in the hope of getting the patch in, I'd like to have
>>> less outstanding patches :) (I have quite a few and new releases
>>> can become painful!)
>>>
>>> gcc/ChangeLog
>>>
>>> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
>>> config.host (arm*-*-netbsd*): Build driver-arm.o
>>> config/arm/netbsd-eabi.h: New file.
>>> config/arm/netbsd-elf.h
>>> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
>>>
>>> libgcc/ChangeLog
>>>
>>> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
>>> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
>>> 		     HOST_LIBGCC2_CFLAGS: workaround possible bug
>>> config/arm/t-netbsd-eabi: New file.
>> So we're well into stage4 which means technically it's too late for
>> something like this.  However, given it's limited scope I won't object
>> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
>> for gcc-10.
>>
>> jeff
>>
> 
> I was about to approve this (modulo removing the now obsolete
> FPU_DEFAULT macro), until I noticed that it also modifies the generic
> NetBSD code as well.  I'm certainly not willing to approve that myself
> at this late stage, but if one of the NetBSD OS maintainers wants to
> step up and do so, I'll happily take the Arm back-end code as that's not
> a primary or secondary target.
So is removal of the FPUTYPE_DEFAULT stuff all that's needed for this to
go forward now that Jason T has chimed in?

jeff
Richard Earnshaw (lists) May 23, 2019, 2:03 p.m. UTC | #7
On 20/05/2019 20:24, Jeff Law wrote:
> On 4/9/19 10:36 AM, Richard Earnshaw (lists) wrote:
>> On 09/04/2019 16:04, Jeff Law wrote:
>>> On 4/8/19 9:17 AM, coypu@sdf.org wrote:
>>>> Pinging again in the hope of getting the patch in, I'd like to have
>>>> less outstanding patches :) (I have quite a few and new releases
>>>> can become painful!)
>>>>
>>>> gcc/ChangeLog
>>>>
>>>> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
>>>> config.host (arm*-*-netbsd*): Build driver-arm.o
>>>> config/arm/netbsd-eabi.h: New file.
>>>> config/arm/netbsd-elf.h
>>>> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
>>>>
>>>> libgcc/ChangeLog
>>>>
>>>> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
>>>> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
>>>> 		     HOST_LIBGCC2_CFLAGS: workaround possible bug
>>>> config/arm/t-netbsd-eabi: New file.
>>> So we're well into stage4 which means technically it's too late for
>>> something like this.  However, given it's limited scope I won't object
>>> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
>>> for gcc-10.
>>>
>>> jeff
>>>
>>
>> I was about to approve this (modulo removing the now obsolete
>> FPU_DEFAULT macro), until I noticed that it also modifies the generic
>> NetBSD code as well.  I'm certainly not willing to approve that myself
>> at this late stage, but if one of the NetBSD OS maintainers wants to
>> step up and do so, I'll happily take the Arm back-end code as that's not
>> a primary or secondary target.
> So is removal of the FPUTYPE_DEFAULT stuff all that's needed for this to
> go forward now that Jason T has chimed in?
> 
> jeff
> 
> 

Very close.  I was just doing a last pass through the patch to make that
small edit when I noticed this in config/arm/netbsd-eabi.h:


#define SUBTARGET_EXTRA_ASM_SPEC		\
  "-matpcs ..."

Why is the assembler unconditionally passed -matpcs for an eabi
configuration?  That sounds broken.

R.
Richard Earnshaw (lists) May 23, 2019, 2:11 p.m. UTC | #8
On 23/05/2019 15:03, Richard Earnshaw (lists) wrote:
> On 20/05/2019 20:24, Jeff Law wrote:
>> On 4/9/19 10:36 AM, Richard Earnshaw (lists) wrote:
>>> On 09/04/2019 16:04, Jeff Law wrote:
>>>> On 4/8/19 9:17 AM, coypu@sdf.org wrote:
>>>>> Pinging again in the hope of getting the patch in, I'd like to have
>>>>> less outstanding patches :) (I have quite a few and new releases
>>>>> can become painful!)
>>>>>
>>>>> gcc/ChangeLog
>>>>>
>>>>> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
>>>>> config.host (arm*-*-netbsd*): Build driver-arm.o
>>>>> config/arm/netbsd-eabi.h: New file.
>>>>> config/arm/netbsd-elf.h
>>>>> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
>>>>>
>>>>> libgcc/ChangeLog
>>>>>
>>>>> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
>>>>> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
>>>>> 		     HOST_LIBGCC2_CFLAGS: workaround possible bug
>>>>> config/arm/t-netbsd-eabi: New file.
>>>> So we're well into stage4 which means technically it's too late for
>>>> something like this.  However, given it's limited scope I won't object
>>>> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
>>>> for gcc-10.
>>>>
>>>> jeff
>>>>
>>>
>>> I was about to approve this (modulo removing the now obsolete
>>> FPU_DEFAULT macro), until I noticed that it also modifies the generic
>>> NetBSD code as well.  I'm certainly not willing to approve that myself
>>> at this late stage, but if one of the NetBSD OS maintainers wants to
>>> step up and do so, I'll happily take the Arm back-end code as that's not
>>> a primary or secondary target.
>> So is removal of the FPUTYPE_DEFAULT stuff all that's needed for this to
>> go forward now that Jason T has chimed in?
>>
>> jeff
>>
>>
> 
> Very close.  I was just doing a last pass through the patch to make that
> small edit when I noticed this in config/arm/netbsd-eabi.h:
> 
> 
> #define SUBTARGET_EXTRA_ASM_SPEC		\
>   "-matpcs ..."
> 
> Why is the assembler unconditionally passed -matpcs for an eabi
> configuration?  That sounds broken.
> 
> R.
> 


Looking at what GAS does with this flag, it simply causes the assembler
to create an empty .arm.atpcs debug section.  On that basis, I would
expect that it's then safe (and correct) to remove this: the EABI is not
the ATPCS.

R.
Richard Earnshaw (lists) May 23, 2019, 4:01 p.m. UTC | #9
On 23/05/2019 15:11, Richard Earnshaw (lists) wrote:
> On 23/05/2019 15:03, Richard Earnshaw (lists) wrote:
>> On 20/05/2019 20:24, Jeff Law wrote:
>>> On 4/9/19 10:36 AM, Richard Earnshaw (lists) wrote:
>>>> On 09/04/2019 16:04, Jeff Law wrote:
>>>>> On 4/8/19 9:17 AM, coypu@sdf.org wrote:
>>>>>> Pinging again in the hope of getting the patch in, I'd like to have
>>>>>> less outstanding patches :) (I have quite a few and new releases
>>>>>> can become painful!)
>>>>>>
>>>>>> gcc/ChangeLog
>>>>>>
>>>>>> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
>>>>>> config.host (arm*-*-netbsd*): Build driver-arm.o
>>>>>> config/arm/netbsd-eabi.h: New file.
>>>>>> config/arm/netbsd-elf.h
>>>>>> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
>>>>>>
>>>>>> libgcc/ChangeLog
>>>>>>
>>>>>> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
>>>>>> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
>>>>>> 		     HOST_LIBGCC2_CFLAGS: workaround possible bug
>>>>>> config/arm/t-netbsd-eabi: New file.
>>>>> So we're well into stage4 which means technically it's too late for
>>>>> something like this.  However, given it's limited scope I won't object
>>>>> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
>>>>> for gcc-10.
>>>>>
>>>>> jeff
>>>>>
>>>>
>>>> I was about to approve this (modulo removing the now obsolete
>>>> FPU_DEFAULT macro), until I noticed that it also modifies the generic
>>>> NetBSD code as well.  I'm certainly not willing to approve that myself
>>>> at this late stage, but if one of the NetBSD OS maintainers wants to
>>>> step up and do so, I'll happily take the Arm back-end code as that's not
>>>> a primary or secondary target.
>>> So is removal of the FPUTYPE_DEFAULT stuff all that's needed for this to
>>> go forward now that Jason T has chimed in?
>>>
>>> jeff
>>>
>>>
>>
>> Very close.  I was just doing a last pass through the patch to make that
>> small edit when I noticed this in config/arm/netbsd-eabi.h:
>>
>>
>> #define SUBTARGET_EXTRA_ASM_SPEC		\
>>   "-matpcs ..."
>>
>> Why is the assembler unconditionally passed -matpcs for an eabi
>> configuration?  That sounds broken.
>>
>> R.
>>
> 
> 
> Looking at what GAS does with this flag, it simply causes the assembler
> to create an empty .arm.atpcs debug section.  On that basis, I would
> expect that it's then safe (and correct) to remove this: the EABI is not
> the ATPCS.
> 
> R.
> 


Finally, I need the names of the authors and their email addresses in a
format suitable for the ChangeLog file.  As far as I can tell, that means:

Yourself
Matt Thomas
Matthew Green
Nick Hudson

R.
Ramana Radhakrishnan May 23, 2019, 4:09 p.m. UTC | #10
On Thu, May 23, 2019 at 3:12 PM Richard Earnshaw (lists)
<Richard.Earnshaw@arm.com> wrote:
>
> On 23/05/2019 15:03, Richard Earnshaw (lists) wrote:
> > On 20/05/2019 20:24, Jeff Law wrote:
> >> On 4/9/19 10:36 AM, Richard Earnshaw (lists) wrote:
> >>> On 09/04/2019 16:04, Jeff Law wrote:
> >>>> On 4/8/19 9:17 AM, coypu@sdf.org wrote:
> >>>>> Pinging again in the hope of getting the patch in, I'd like to have
> >>>>> less outstanding patches :) (I have quite a few and new releases
> >>>>> can become painful!)
> >>>>>
> >>>>> gcc/ChangeLog
> >>>>>
> >>>>> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
> >>>>> config.host (arm*-*-netbsd*): Build driver-arm.o
> >>>>> config/arm/netbsd-eabi.h: New file.
> >>>>> config/arm/netbsd-elf.h
> >>>>> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
> >>>>>
> >>>>> libgcc/ChangeLog
> >>>>>
> >>>>> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
> >>>>> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
> >>>>>                HOST_LIBGCC2_CFLAGS: workaround possible bug
> >>>>> config/arm/t-netbsd-eabi: New file.
> >>>> So we're well into stage4 which means technically it's too late for
> >>>> something like this.  However, given it's limited scope I won't object
> >>>> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
> >>>> for gcc-10.
> >>>>
> >>>> jeff
> >>>>
> >>>
> >>> I was about to approve this (modulo removing the now obsolete
> >>> FPU_DEFAULT macro), until I noticed that it also modifies the generic
> >>> NetBSD code as well.  I'm certainly not willing to approve that myself
> >>> at this late stage, but if one of the NetBSD OS maintainers wants to
> >>> step up and do so, I'll happily take the Arm back-end code as that's not
> >>> a primary or secondary target.
> >> So is removal of the FPUTYPE_DEFAULT stuff all that's needed for this to
> >> go forward now that Jason T has chimed in?
> >>
> >> jeff
> >>
> >>
> >
> > Very close.  I was just doing a last pass through the patch to make that
> > small edit when I noticed this in config/arm/netbsd-eabi.h:
> >
> >
> > #define SUBTARGET_EXTRA_ASM_SPEC              \
> >   "-matpcs ..."
> >
> > Why is the assembler unconditionally passed -matpcs for an eabi
> > configuration?  That sounds broken.
> >
> > R.
> >
>
>
> Looking at what GAS does with this flag, it simply causes the assembler
> to create an empty .arm.atpcs debug section.  On that basis, I would
> expect that it's then safe (and correct) to remove this: the EABI is not
> the ATPCS.
>

I'm not sure if this has been asked. Do you and the other authors have
a copyright assignment on file with the FSF ? I don't see any one with
the email coypu@sdf.org on the copyright file . I think this has been
asked in terms of the vax netbsd patches.

regards
Ramana


> R.
>
Richard Earnshaw (lists) May 23, 2019, 4:11 p.m. UTC | #11
On 23/05/2019 17:01, Richard Earnshaw (lists) wrote:
> On 23/05/2019 15:11, Richard Earnshaw (lists) wrote:
>> On 23/05/2019 15:03, Richard Earnshaw (lists) wrote:
>>> On 20/05/2019 20:24, Jeff Law wrote:
>>>> On 4/9/19 10:36 AM, Richard Earnshaw (lists) wrote:
>>>>> On 09/04/2019 16:04, Jeff Law wrote:
>>>>>> On 4/8/19 9:17 AM, coypu@sdf.org wrote:
>>>>>>> Pinging again in the hope of getting the patch in, I'd like to have
>>>>>>> less outstanding patches :) (I have quite a few and new releases
>>>>>>> can become painful!)
>>>>>>>
>>>>>>> gcc/ChangeLog
>>>>>>>
>>>>>>> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
>>>>>>> config.host (arm*-*-netbsd*): Build driver-arm.o
>>>>>>> config/arm/netbsd-eabi.h: New file.
>>>>>>> config/arm/netbsd-elf.h
>>>>>>> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
>>>>>>>
>>>>>>> libgcc/ChangeLog
>>>>>>>
>>>>>>> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
>>>>>>> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
>>>>>>> 		     HOST_LIBGCC2_CFLAGS: workaround possible bug
>>>>>>> config/arm/t-netbsd-eabi: New file.
>>>>>> So we're well into stage4 which means technically it's too late for
>>>>>> something like this.  However, given it's limited scope I won't object
>>>>>> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
>>>>>> for gcc-10.
>>>>>>
>>>>>> jeff
>>>>>>
>>>>>
>>>>> I was about to approve this (modulo removing the now obsolete
>>>>> FPU_DEFAULT macro), until I noticed that it also modifies the generic
>>>>> NetBSD code as well.  I'm certainly not willing to approve that myself
>>>>> at this late stage, but if one of the NetBSD OS maintainers wants to
>>>>> step up and do so, I'll happily take the Arm back-end code as that's not
>>>>> a primary or secondary target.
>>>> So is removal of the FPUTYPE_DEFAULT stuff all that's needed for this to
>>>> go forward now that Jason T has chimed in?
>>>>
>>>> jeff
>>>>
>>>>
>>>
>>> Very close.  I was just doing a last pass through the patch to make that
>>> small edit when I noticed this in config/arm/netbsd-eabi.h:
>>>
>>>
>>> #define SUBTARGET_EXTRA_ASM_SPEC		\
>>>   "-matpcs ..."
>>>
>>> Why is the assembler unconditionally passed -matpcs for an eabi
>>> configuration?  That sounds broken.
>>>
>>> R.
>>>
>>
>>
>> Looking at what GAS does with this flag, it simply causes the assembler
>> to create an empty .arm.atpcs debug section.  On that basis, I would
>> expect that it's then safe (and correct) to remove this: the EABI is not
>> the ATPCS.
>>
>> R.
>>
> 
> 
> Finally, I need the names of the authors and their email addresses in a
> format suitable for the ChangeLog file.  As far as I can tell, that means:
> 
> Yourself
> Matt Thomas
> Matthew Green
> Nick Hudson
> 
> R.
> 

Argh, there's a final issue.  We can't find a copyright assignment
against your email address.  Do you have one?

R.
Maya Rashish May 23, 2019, 4:35 p.m. UTC | #12
On Thu, May 23, 2019 at 05:11:30PM +0100, Richard Earnshaw (lists) wrote:
> On 23/05/2019 17:01, Richard Earnshaw (lists) wrote:
> > On 23/05/2019 15:11, Richard Earnshaw (lists) wrote:
> >> On 23/05/2019 15:03, Richard Earnshaw (lists) wrote:
> >>> On 20/05/2019 20:24, Jeff Law wrote:
> >>>> On 4/9/19 10:36 AM, Richard Earnshaw (lists) wrote:
> >>>>> On 09/04/2019 16:04, Jeff Law wrote:
> >>>>>> On 4/8/19 9:17 AM, coypu@sdf.org wrote:
> >>>>>>> Pinging again in the hope of getting the patch in, I'd like to have
> >>>>>>> less outstanding patches :) (I have quite a few and new releases
> >>>>>>> can become painful!)
> >>>>>>>
> >>>>>>> gcc/ChangeLog
> >>>>>>>
> >>>>>>> config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
> >>>>>>> config.host (arm*-*-netbsd*): Build driver-arm.o
> >>>>>>> config/arm/netbsd-eabi.h: New file.
> >>>>>>> config/arm/netbsd-elf.h
> >>>>>>> config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
> >>>>>>>
> >>>>>>> libgcc/ChangeLog
> >>>>>>>
> >>>>>>> config.host (arm*-*-netbsdelf*): Add support for EABI configuration
> >>>>>>> config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
> >>>>>>> 		     HOST_LIBGCC2_CFLAGS: workaround possible bug
> >>>>>>> config/arm/t-netbsd-eabi: New file.
> >>>>>> So we're well into stage4 which means technically it's too late for
> >>>>>> something like this.  However, given it's limited scope I won't object
> >>>>>> if the ARM port maintainers want to go forward.  Otherwise I'll queue it
> >>>>>> for gcc-10.
> >>>>>>
> >>>>>> jeff
> >>>>>>
> >>>>>
> >>>>> I was about to approve this (modulo removing the now obsolete
> >>>>> FPU_DEFAULT macro), until I noticed that it also modifies the generic
> >>>>> NetBSD code as well.  I'm certainly not willing to approve that myself
> >>>>> at this late stage, but if one of the NetBSD OS maintainers wants to
> >>>>> step up and do so, I'll happily take the Arm back-end code as that's not
> >>>>> a primary or secondary target.
> >>>> So is removal of the FPUTYPE_DEFAULT stuff all that's needed for this to
> >>>> go forward now that Jason T has chimed in?
> >>>>
> >>>> jeff
> >>>>
> >>>>
> >>>
> >>> Very close.  I was just doing a last pass through the patch to make that
> >>> small edit when I noticed this in config/arm/netbsd-eabi.h:
> >>>
> >>>
> >>> #define SUBTARGET_EXTRA_ASM_SPEC		\
> >>>   "-matpcs ..."
> >>>
> >>> Why is the assembler unconditionally passed -matpcs for an eabi
> >>> configuration?  That sounds broken.
> >>>
> >>> R.
> >>>
> >>
> >>
> >> Looking at what GAS does with this flag, it simply causes the assembler
> >> to create an empty .arm.atpcs debug section.  On that basis, I would
> >> expect that it's then safe (and correct) to remove this: the EABI is not
> >> the ATPCS.
> >>
> >> R.
> >>
> > 
> > 
> > Finally, I need the names of the authors and their email addresses in a
> > format suitable for the ChangeLog file.  As far as I can tell, that means:
> > 
> > Yourself
> > Matt Thomas
> > Matthew Green
> > Nick Hudson
> > 
> > R.
> > 
> 
> Argh, there's a final issue.  We can't find a copyright assignment
> against your email address.  Do you have one?
> 
> R.

Unfortunately no :-(
How do I do it?
Maya Rashish June 12, 2019, 4:19 p.m. UTC | #13
I think copyright assignment is done. Thanks for bearing with me.

I noticed the version I submitted in April is missing some changes we
discussed on October 2018.

I took the patch from then and removed -matpcs too, the unnecessary
change to libgcc t-netbsd (which is the OABI configuration anyway), and
some whitespace git warned about.

Added the change to libatomic ifunc usage, since we recently claim ifunc
support on netbsd.
(Got lost in https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00290.html -
that one is my fault for submitting patches badly)


Matt Thomas <matt@3am-software.com>
matthew green <mrg@eterna.com.au>
Nick Hudson <skrll@netbsd.org>
Maya Rashish <coypu@sdf.org>

gcc/ChangeLog:

	* config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
	* config.host (arm*-*-netbsd*): Build driver-arm.o
	* config/arm/netbsd-eabi.h: New file.
	* config/arm/netbsd-elf.h: Don't pass -matpcs unconditionally.
	* config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.

libgcc/ChangeLog:

	* config.host (arm*-*-netbsdelf*): Add support for EABI configuration
	* config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
			     HOST_LIBGCC2_CFLAGS: workaround possible bug
	* config/arm/t-netbsd-eabi: New file.

libatomic/ChangeLog:
        * configure.tgt: Exclude arm*-*-netbsd* from try_ifunc.



---
 gcc/config.gcc                  | 29 +++++++++-
 gcc/config.host                 |  2 +-
 gcc/config/arm/netbsd-eabi.h    | 97 +++++++++++++++++++++++++++++++++
 gcc/config/arm/netbsd-elf.h     |  3 +-
 gcc/config/netbsd-elf.h         | 14 +++++
 libatomic/configure.tgt         |  2 +-
 libgcc/config.host              | 11 +++-
 libgcc/config/arm/t-netbsd      |  8 +++
 libgcc/config/arm/t-netbsd-eabi | 18 ++++++
 9 files changed, 177 insertions(+), 7 deletions(-)
 create mode 100644 gcc/config/arm/netbsd-eabi.h
 create mode 100644 libgcc/config/arm/t-netbsd-eabi

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 6b00c387247..9fe57f4c7de 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1159,10 +1159,33 @@ arm*-*-freebsd*)                # ARM FreeBSD EABI
 	with_tls=${with_tls:-gnu}
 	;;
 arm*-*-netbsdelf*)
-	tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h arm/aout.h ${tm_file} arm/netbsd-elf.h"
-	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
-	tmake_file="${tmake_file} arm/t-arm"
 	target_cpu_cname="strongarm"
+	tmake_file="${tmake_file} arm/t-arm"
+	tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h"
+	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
+	case ${target} in
+	arm*eb-*) tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1" ;;
+	esac
+	case ${target} in
+	arm*-*-netbsdelf-*eabi*)
+	    tm_file="$tm_file arm/bpabi.h arm/netbsd-elf.h arm/netbsd-eabi.h"
+	    tmake_file="$tmake_file arm/t-bpabi arm/t-netbsdeabi"
+	    ;;
+	*)
+	    tm_file="$tm_file arm/netbsd-elf.h"
+	    tmake_file="$tmake_file arm/t-netbsd"
+	    ;;
+	esac
+	tm_file="${tm_file} arm/aout.h arm/arm.h"
+	case ${target} in
+	arm*-*-netbsdelf-*eabihf*)
+	    tm_defines="${tm_defines} TARGET_DEFAULT_FLOAT_ABI=ARM_FLOAT_ABI_HARD"
+	    ;;
+	esac
+	case ${target} in
+	armv6*) target_cpu_cname="arm1176jzf-s";;
+	armv7*) target_cpu_cname="generic-armv7-a";;
+	esac
 	;;
 arm*-*-linux-*)			# ARM GNU/Linux with ELF
 	tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
diff --git a/gcc/config.host b/gcc/config.host
index 2213404dd0e..82409e32f96 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -107,7 +107,7 @@ case ${host} in
 	;;
     esac
     ;;
-  arm*-*-freebsd* | arm*-*-linux* | arm*-*-fuchsia*)
+  arm*-*-freebsd* | arm*-*-netbsd* | arm*-*-linux* | arm*-*-fuchsia*)
     case ${target} in
       arm*-*-*)
 	host_extra_gcc_objs="driver-arm.o"
diff --git a/gcc/config/arm/netbsd-eabi.h b/gcc/config/arm/netbsd-eabi.h
new file mode 100644
index 00000000000..5cbfcc92a59
--- /dev/null
+++ b/gcc/config/arm/netbsd-eabi.h
@@ -0,0 +1,97 @@
+/* Definitions of target machine for GNU compiler, NetBSD/arm ELF version.
+   Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Contributed by Wasabi Systems, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Run-time Target Specification.  */
+#undef MULTILIB_DEFAULTS
+#define MULTILIB_DEFAULTS { "mabi=aapcs-linux" }
+
+#define TARGET_LINKER_EABI_SUFFIX \
+    (TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_SOFT \
+     ? "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=hard:_eabihf;:_eabi}}}" \
+     : "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=soft:_eabi;:_eabihf}}}")
+#define TARGET_LINKER_BIG_EMULATION "armelfb_nbsd%(linker_eabi_suffix)"
+#define TARGET_LINKER_LITTLE_EMULATION "armelf_nbsd%(linker_eabi_suffix)"
+
+/* TARGET_BIG_ENDIAN_DEFAULT is set in
+   config.gcc for big endian configurations.  */
+#undef  TARGET_LINKER_EMULATION
+#if TARGET_BIG_ENDIAN_DEFAULT
+#define TARGET_LINKER_EMULATION TARGET_LINKER_BIG_EMULATION
+#else
+#define TARGET_LINKER_EMULATION TARGET_LINKER_LITTLE_EMULATION
+#endif
+
+#undef ARM_DEFAULT_ABI
+#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX
+
+#undef ARM_UNWIND_INFO
+#define ARM_UNWIND_INFO 0
+#undef DWARF2_UNWIND_INFO
+#define DWARF2_UNWIND_INFO 1
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS()		\
+  do						\
+    {						\
+      if (TARGET_AAPCS_BASED)			\
+	TARGET_BPABI_CPP_BUILTINS();		\
+      NETBSD_OS_CPP_BUILTINS_ELF();		\
+      if (DWARF2_UNWIND_INFO)			\
+	builtin_define ("__ARM_DWARF_EH__");	\
+    }						\
+  while (0)
+
+#undef SUBTARGET_CPP_SPEC
+#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
+
+/*
+ * Override AAPCS types to remain compatible the existing NetBSD types.
+ */
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef SIZE_TYPE
+#define SIZE_TYPE "long unsigned int"
+
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "long int"
+
+#undef SUBTARGET_EXTRA_ASM_SPEC
+#define SUBTARGET_EXTRA_ASM_SPEC	\
+  "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu} %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
+
+#undef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS				\
+  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC }, \
+  { "linker_eabi_suffix",	TARGET_LINKER_EABI_SUFFIX }, \
+  { "linker_emulation",		TARGET_LINKER_EMULATION }, \
+  { "linker_big_emulation",	TARGET_LINKER_BIG_EMULATION }, \
+  { "linker_little_emulation",	TARGET_LINKER_LITTLE_EMULATION }, \
+  { "target_fix_v4bx_spec",	TARGET_FIX_V4BX_SPEC }, \
+  NETBSD_SUBTARGET_EXTRA_SPECS
+
+#define NETBSD_ENTRY_POINT "__start"
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+  "-X %{mbig-endian:-EB -m %(linker_big_emulation)} \
+   %{mlittle-endian:-EL -m %(linker_liitle_emulation)} \
+   %{!mbig-endian:%{!mlittle-endian:-m %(linker_emulation)}} \
+   %(target_fix_v4bx_spec) %(netbsd_link_spec)"
diff --git a/gcc/config/arm/netbsd-elf.h b/gcc/config/arm/netbsd-elf.h
index 5fcb543ed5f..1ce04428367 100644
--- a/gcc/config/arm/netbsd-elf.h
+++ b/gcc/config/arm/netbsd-elf.h
@@ -43,6 +43,7 @@
 #undef ARM_DEFAULT_ABI
 #define ARM_DEFAULT_ABI ARM_ABI_ATPCS
 
+#undef TARGET_OS_CPP_BUILTINS
 #define TARGET_OS_CPP_BUILTINS()	\
   do					\
     {					\
@@ -55,7 +56,7 @@
 
 #undef SUBTARGET_EXTRA_ASM_SPEC
 #define SUBTARGET_EXTRA_ASM_SPEC	\
-  "-matpcs %{" FPIE_OR_FPIC_SPEC ":-k}"
+  "%{" FPIE_OR_FPIC_SPEC ":-k}"
 
 /* Default to full VFP if -mfloat-abi=hard is specified.  */
 #undef SUBTARGET_ASM_FLOAT_SPEC
diff --git a/gcc/config/netbsd-elf.h b/gcc/config/netbsd-elf.h
index e35758b9abc..12ebdd673c6 100644
--- a/gcc/config/netbsd-elf.h
+++ b/gcc/config/netbsd-elf.h
@@ -73,6 +73,9 @@ along with GCC; see the file COPYING3.  If not see
 
    Target-specific code must provide the %(netbsd_entry_point) spec.  */
 
+#define NETBSD_LINK_LD_ELF_SO_SPEC \
+  "%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}"
+
 #define NETBSD_LINK_SPEC_ELF \
   "%{assert*} %{R*} %{rpath*} \
    %{shared:-shared} \
@@ -87,6 +90,17 @@ along with GCC; see the file COPYING3.  If not see
        -dynamic-linker /usr/libexec/ld.elf_so} \
      %{static:-static}}"
 
+/* Provide the standard list of subtarget extra specs for NetBSD targets.  */
+#define NETBSD_SUBTARGET_EXTRA_SPECS \
+  { "netbsd_link_ld_elf_so",    NETBSD_LINK_LD_ELF_SO_SPEC }, \
+  { "netbsd_cpp_spec",          NETBSD_CPP_SPEC }, \
+  { "netbsd_link_spec",         NETBSD_LINK_SPEC_ELF }, \
+  { "netbsd_entry_point",       NETBSD_ENTRY_POINT }, \
+  { "netbsd_endfile_spec",      NETBSD_ENDFILE_SPEC },
+
+#undef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS   NETBSD_SUBTARGET_EXTRA_SPECS
+
 /* Use --as-needed -lgcc_s for eh support.  */
 #ifdef HAVE_LD_AS_NEEDED
 #define USE_LD_AS_NEEDED 1
diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
index ecbb7d33cc1..4a1294bc1ff 100644
--- a/libatomic/configure.tgt
+++ b/libatomic/configure.tgt
@@ -53,7 +53,7 @@ case "${target_cpu}" in
   arm*)
 	ARCH=arm
 	case "${target}" in
-            arm*-*-freebsd*)
+            arm*-*-freebsd* | arm*-*-netbsd*)
                 ;;
             *)
                 # ??? Detect when -march=armv7 is already enabled.
diff --git a/libgcc/config.host b/libgcc/config.host
index d75e2b5d7aa..008892135ee 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -433,7 +433,16 @@ arm*-*-fuchsia*)
 	unwind_header=config/arm/unwind-arm.h
 	;;
 arm*-*-netbsdelf*)
-	tmake_file="$tmake_file arm/t-arm arm/t-netbsd t-slibgcc-gld-nover"
+	tmake_file="$tmake_file arm/t-arm"
+	case ${host} in
+	  arm*-*-netbsdelf-*eabi*)
+	    tmake_file="${tmake_file} arm/t-netbsd-eabi"
+	    unwind_header=config/arm/unwind-arm.h
+	    ;;
+	  *)
+	    tmake_file="${tmake_file} arm/t-netbsd t-slibgcc-gld-nover"
+	    ;;
+	esac
 	;;
 arm*-*-linux*)			# ARM GNU/Linux with ELF
 	tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix t-crtfm"
diff --git a/libgcc/config/arm/t-netbsd b/libgcc/config/arm/t-netbsd
index 95358f931ba..ea4d5de4e77 100644
--- a/libgcc/config/arm/t-netbsd
+++ b/libgcc/config/arm/t-netbsd
@@ -1,3 +1,11 @@
+# This list is from t-elf, but with some things removed.
+LIB1ASMFUNCS += _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func \
+	_call_via_rX _interwork_call_via_rX \
+	_arm_fixunsdfsi _arm_fixunssfsi \
+	_arm_floatdidf _arm_floatdisf _arm_floatundidf _arm_floatundisf \
+	_lshrdi3 _ashrdi3 _ashldi3 \
+	_clzsi2 _clzdi2 _ctzsi2
+
 # Just for these, we omit the frame pointer since it makes such a big
 # difference.  It is then pointless adding debugging.
 HOST_LIBGCC2_CFLAGS += -fomit-frame-pointer
diff --git a/libgcc/config/arm/t-netbsd-eabi b/libgcc/config/arm/t-netbsd-eabi
new file mode 100644
index 00000000000..ae08ea43ef7
--- /dev/null
+++ b/libgcc/config/arm/t-netbsd-eabi
@@ -0,0 +1,18 @@
+# This list is from t-elf, but with lots removed.
+LIB1ASMFUNCS += _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX \
+        _clzsi2 _clzdi2 _ctzsi2
+
+# Derived from t-bpabi
+# Add the BPABI C functions.
+LIB2ADD +=    $(srcdir)/config/arm/unaligned-funcs.c
+
+# Not using libgcc for EH.
+LIB2ADDEH =
+
+# Add the BPABI names.
+SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver
+
+# On ARM, specifying -fnon-call-exceptions will needlessly pull in
+# the unwinder in simple programs which use 64-bit division.  Omitting
+# the option is safe.
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions
Richard Earnshaw (lists) June 14, 2019, 2:06 p.m. UTC | #14
On 12/06/2019 17:19, coypu@sdf.org wrote:
> I think copyright assignment is done. Thanks for bearing with me.
> 
> I noticed the version I submitted in April is missing some changes we
> discussed on October 2018.
> 
> I took the patch from then and removed -matpcs too, the unnecessary
> change to libgcc t-netbsd (which is the OABI configuration anyway), and
> some whitespace git warned about.
> 
> Added the change to libatomic ifunc usage, since we recently claim ifunc
> support on netbsd.
> (Got lost in https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00290.html -
> that one is my fault for submitting patches badly)
> 
> 
> Matt Thomas <matt@3am-software.com>
> matthew green <mrg@eterna.com.au>
> Nick Hudson <skrll@netbsd.org>
> Maya Rashish <coypu@sdf.org>
> 

Thanks.  I've made a couple of minor tweaks and committed the attached.
 Thanks for posting all this and thanks for bearing with us while we
sorted out the copyright issues.

R.

> gcc/ChangeLog:
> 
> 	* config.gcc (arm*-*-netbsdelf*) Add support for EABI configuration
> 	* config.host (arm*-*-netbsd*): Build driver-arm.o
> 	* config/arm/netbsd-eabi.h: New file.
> 	* config/arm/netbsd-elf.h: Don't pass -matpcs unconditionally.
> 	* config/netbsd-elf.h: Define SUBTARGET_EXTRA_SPECS.
> 
> libgcc/ChangeLog:
> 
> 	* config.host (arm*-*-netbsdelf*): Add support for EABI configuration
> 	* config/arm/t-netbsd: LIB1ASMFUNCS: Append to existing set.
> 			     HOST_LIBGCC2_CFLAGS: workaround possible bug
> 	* config/arm/t-netbsd-eabi: New file.
> 
> libatomic/ChangeLog:
>         * configure.tgt: Exclude arm*-*-netbsd* from try_ifunc.
> 
> 
> 
> ---
>  gcc/config.gcc                  | 29 +++++++++-
>  gcc/config.host                 |  2 +-
>  gcc/config/arm/netbsd-eabi.h    | 97 +++++++++++++++++++++++++++++++++
>  gcc/config/arm/netbsd-elf.h     |  3 +-
>  gcc/config/netbsd-elf.h         | 14 +++++
>  libatomic/configure.tgt         |  2 +-
>  libgcc/config.host              | 11 +++-
>  libgcc/config/arm/t-netbsd      |  8 +++
>  libgcc/config/arm/t-netbsd-eabi | 18 ++++++
>  9 files changed, 177 insertions(+), 7 deletions(-)
>  create mode 100644 gcc/config/arm/netbsd-eabi.h
>  create mode 100644 libgcc/config/arm/t-netbsd-eabi
> 
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 6b00c387247..9fe57f4c7de 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -1159,10 +1159,33 @@ arm*-*-freebsd*)                # ARM FreeBSD EABI
>  	with_tls=${with_tls:-gnu}
>  	;;
>  arm*-*-netbsdelf*)
> -	tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h arm/aout.h ${tm_file} arm/netbsd-elf.h"
> -	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
> -	tmake_file="${tmake_file} arm/t-arm"
>  	target_cpu_cname="strongarm"
> +	tmake_file="${tmake_file} arm/t-arm"
> +	tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h"
> +	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
> +	case ${target} in
> +	arm*eb-*) tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1" ;;
> +	esac
> +	case ${target} in
> +	arm*-*-netbsdelf-*eabi*)
> +	    tm_file="$tm_file arm/bpabi.h arm/netbsd-elf.h arm/netbsd-eabi.h"
> +	    tmake_file="$tmake_file arm/t-bpabi arm/t-netbsdeabi"
> +	    ;;
> +	*)
> +	    tm_file="$tm_file arm/netbsd-elf.h"
> +	    tmake_file="$tmake_file arm/t-netbsd"
> +	    ;;
> +	esac
> +	tm_file="${tm_file} arm/aout.h arm/arm.h"
> +	case ${target} in
> +	arm*-*-netbsdelf-*eabihf*)
> +	    tm_defines="${tm_defines} TARGET_DEFAULT_FLOAT_ABI=ARM_FLOAT_ABI_HARD"
> +	    ;;
> +	esac
> +	case ${target} in
> +	armv6*) target_cpu_cname="arm1176jzf-s";;
> +	armv7*) target_cpu_cname="generic-armv7-a";;
> +	esac
>  	;;
>  arm*-*-linux-*)			# ARM GNU/Linux with ELF
>  	tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
> diff --git a/gcc/config.host b/gcc/config.host
> index 2213404dd0e..82409e32f96 100644
> --- a/gcc/config.host
> +++ b/gcc/config.host
> @@ -107,7 +107,7 @@ case ${host} in
>  	;;
>      esac
>      ;;
> -  arm*-*-freebsd* | arm*-*-linux* | arm*-*-fuchsia*)
> +  arm*-*-freebsd* | arm*-*-netbsd* | arm*-*-linux* | arm*-*-fuchsia*)
>      case ${target} in
>        arm*-*-*)
>  	host_extra_gcc_objs="driver-arm.o"
> diff --git a/gcc/config/arm/netbsd-eabi.h b/gcc/config/arm/netbsd-eabi.h
> new file mode 100644
> index 00000000000..5cbfcc92a59
> --- /dev/null
> +++ b/gcc/config/arm/netbsd-eabi.h
> @@ -0,0 +1,97 @@
> +/* Definitions of target machine for GNU compiler, NetBSD/arm ELF version.
> +   Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
> +   Contributed by Wasabi Systems, Inc.
> +
> +   This file is part of GCC.
> +
> +   GCC is free software; you can redistribute it and/or modify it
> +   under the terms of the GNU General Public License as published
> +   by the Free Software Foundation; either version 3, or (at your
> +   option) any later version.
> +
> +   GCC is distributed in the hope that it will be useful, but WITHOUT
> +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> +   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
> +   License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with GCC; see the file COPYING3.  If not see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +/* Run-time Target Specification.  */
> +#undef MULTILIB_DEFAULTS
> +#define MULTILIB_DEFAULTS { "mabi=aapcs-linux" }
> +
> +#define TARGET_LINKER_EABI_SUFFIX \
> +    (TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_SOFT \
> +     ? "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=hard:_eabihf;:_eabi}}}" \
> +     : "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=soft:_eabi;:_eabihf}}}")
> +#define TARGET_LINKER_BIG_EMULATION "armelfb_nbsd%(linker_eabi_suffix)"
> +#define TARGET_LINKER_LITTLE_EMULATION "armelf_nbsd%(linker_eabi_suffix)"
> +
> +/* TARGET_BIG_ENDIAN_DEFAULT is set in
> +   config.gcc for big endian configurations.  */
> +#undef  TARGET_LINKER_EMULATION
> +#if TARGET_BIG_ENDIAN_DEFAULT
> +#define TARGET_LINKER_EMULATION TARGET_LINKER_BIG_EMULATION
> +#else
> +#define TARGET_LINKER_EMULATION TARGET_LINKER_LITTLE_EMULATION
> +#endif
> +
> +#undef ARM_DEFAULT_ABI
> +#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX
> +
> +#undef ARM_UNWIND_INFO
> +#define ARM_UNWIND_INFO 0
> +#undef DWARF2_UNWIND_INFO
> +#define DWARF2_UNWIND_INFO 1
> +
> +#undef TARGET_OS_CPP_BUILTINS
> +#define TARGET_OS_CPP_BUILTINS()		\
> +  do						\
> +    {						\
> +      if (TARGET_AAPCS_BASED)			\
> +	TARGET_BPABI_CPP_BUILTINS();		\
> +      NETBSD_OS_CPP_BUILTINS_ELF();		\
> +      if (DWARF2_UNWIND_INFO)			\
> +	builtin_define ("__ARM_DWARF_EH__");	\
> +    }						\
> +  while (0)
> +
> +#undef SUBTARGET_CPP_SPEC
> +#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
> +
> +/*
> + * Override AAPCS types to remain compatible the existing NetBSD types.
> + */
> +#undef WCHAR_TYPE
> +#define WCHAR_TYPE "int"
> +
> +#undef SIZE_TYPE
> +#define SIZE_TYPE "long unsigned int"
> +
> +#undef PTRDIFF_TYPE
> +#define PTRDIFF_TYPE "long int"
> +
> +#undef SUBTARGET_EXTRA_ASM_SPEC
> +#define SUBTARGET_EXTRA_ASM_SPEC	\
> +  "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu} %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
> +
> +#undef SUBTARGET_EXTRA_SPECS
> +#define SUBTARGET_EXTRA_SPECS				\
> +  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC }, \
> +  { "linker_eabi_suffix",	TARGET_LINKER_EABI_SUFFIX }, \
> +  { "linker_emulation",		TARGET_LINKER_EMULATION }, \
> +  { "linker_big_emulation",	TARGET_LINKER_BIG_EMULATION }, \
> +  { "linker_little_emulation",	TARGET_LINKER_LITTLE_EMULATION }, \
> +  { "target_fix_v4bx_spec",	TARGET_FIX_V4BX_SPEC }, \
> +  NETBSD_SUBTARGET_EXTRA_SPECS
> +
> +#define NETBSD_ENTRY_POINT "__start"
> +
> +#undef LINK_SPEC
> +#define LINK_SPEC \
> +  "-X %{mbig-endian:-EB -m %(linker_big_emulation)} \
> +   %{mlittle-endian:-EL -m %(linker_liitle_emulation)} \
> +   %{!mbig-endian:%{!mlittle-endian:-m %(linker_emulation)}} \
> +   %(target_fix_v4bx_spec) %(netbsd_link_spec)"
> diff --git a/gcc/config/arm/netbsd-elf.h b/gcc/config/arm/netbsd-elf.h
> index 5fcb543ed5f..1ce04428367 100644
> --- a/gcc/config/arm/netbsd-elf.h
> +++ b/gcc/config/arm/netbsd-elf.h
> @@ -43,6 +43,7 @@
>  #undef ARM_DEFAULT_ABI
>  #define ARM_DEFAULT_ABI ARM_ABI_ATPCS
>  
> +#undef TARGET_OS_CPP_BUILTINS
>  #define TARGET_OS_CPP_BUILTINS()	\
>    do					\
>      {					\
> @@ -55,7 +56,7 @@
>  
>  #undef SUBTARGET_EXTRA_ASM_SPEC
>  #define SUBTARGET_EXTRA_ASM_SPEC	\
> -  "-matpcs %{" FPIE_OR_FPIC_SPEC ":-k}"
> +  "%{" FPIE_OR_FPIC_SPEC ":-k}"
>  
>  /* Default to full VFP if -mfloat-abi=hard is specified.  */
>  #undef SUBTARGET_ASM_FLOAT_SPEC
> diff --git a/gcc/config/netbsd-elf.h b/gcc/config/netbsd-elf.h
> index e35758b9abc..12ebdd673c6 100644
> --- a/gcc/config/netbsd-elf.h
> +++ b/gcc/config/netbsd-elf.h
> @@ -73,6 +73,9 @@ along with GCC; see the file COPYING3.  If not see
>  
>     Target-specific code must provide the %(netbsd_entry_point) spec.  */
>  
> +#define NETBSD_LINK_LD_ELF_SO_SPEC \
> +  "%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}"
> +
>  #define NETBSD_LINK_SPEC_ELF \
>    "%{assert*} %{R*} %{rpath*} \
>     %{shared:-shared} \
> @@ -87,6 +90,17 @@ along with GCC; see the file COPYING3.  If not see
>         -dynamic-linker /usr/libexec/ld.elf_so} \
>       %{static:-static}}"
>  
> +/* Provide the standard list of subtarget extra specs for NetBSD targets.  */
> +#define NETBSD_SUBTARGET_EXTRA_SPECS \
> +  { "netbsd_link_ld_elf_so",    NETBSD_LINK_LD_ELF_SO_SPEC }, \
> +  { "netbsd_cpp_spec",          NETBSD_CPP_SPEC }, \
> +  { "netbsd_link_spec",         NETBSD_LINK_SPEC_ELF }, \
> +  { "netbsd_entry_point",       NETBSD_ENTRY_POINT }, \
> +  { "netbsd_endfile_spec",      NETBSD_ENDFILE_SPEC },
> +
> +#undef SUBTARGET_EXTRA_SPECS
> +#define SUBTARGET_EXTRA_SPECS   NETBSD_SUBTARGET_EXTRA_SPECS
> +
>  /* Use --as-needed -lgcc_s for eh support.  */
>  #ifdef HAVE_LD_AS_NEEDED
>  #define USE_LD_AS_NEEDED 1
> diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
> index ecbb7d33cc1..4a1294bc1ff 100644
> --- a/libatomic/configure.tgt
> +++ b/libatomic/configure.tgt
> @@ -53,7 +53,7 @@ case "${target_cpu}" in
>    arm*)
>  	ARCH=arm
>  	case "${target}" in
> -            arm*-*-freebsd*)
> +            arm*-*-freebsd* | arm*-*-netbsd*)
>                  ;;
>              *)
>                  # ??? Detect when -march=armv7 is already enabled.
> diff --git a/libgcc/config.host b/libgcc/config.host
> index d75e2b5d7aa..008892135ee 100644
> --- a/libgcc/config.host
> +++ b/libgcc/config.host
> @@ -433,7 +433,16 @@ arm*-*-fuchsia*)
>  	unwind_header=config/arm/unwind-arm.h
>  	;;
>  arm*-*-netbsdelf*)
> -	tmake_file="$tmake_file arm/t-arm arm/t-netbsd t-slibgcc-gld-nover"
> +	tmake_file="$tmake_file arm/t-arm"
> +	case ${host} in
> +	  arm*-*-netbsdelf-*eabi*)
> +	    tmake_file="${tmake_file} arm/t-netbsd-eabi"
> +	    unwind_header=config/arm/unwind-arm.h
> +	    ;;
> +	  *)
> +	    tmake_file="${tmake_file} arm/t-netbsd t-slibgcc-gld-nover"
> +	    ;;
> +	esac
>  	;;
>  arm*-*-linux*)			# ARM GNU/Linux with ELF
>  	tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix t-crtfm"
> diff --git a/libgcc/config/arm/t-netbsd b/libgcc/config/arm/t-netbsd
> index 95358f931ba..ea4d5de4e77 100644
> --- a/libgcc/config/arm/t-netbsd
> +++ b/libgcc/config/arm/t-netbsd
> @@ -1,3 +1,11 @@
> +# This list is from t-elf, but with some things removed.
> +LIB1ASMFUNCS += _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func \
> +	_call_via_rX _interwork_call_via_rX \
> +	_arm_fixunsdfsi _arm_fixunssfsi \
> +	_arm_floatdidf _arm_floatdisf _arm_floatundidf _arm_floatundisf \
> +	_lshrdi3 _ashrdi3 _ashldi3 \
> +	_clzsi2 _clzdi2 _ctzsi2
> +
>  # Just for these, we omit the frame pointer since it makes such a big
>  # difference.  It is then pointless adding debugging.
>  HOST_LIBGCC2_CFLAGS += -fomit-frame-pointer
> diff --git a/libgcc/config/arm/t-netbsd-eabi b/libgcc/config/arm/t-netbsd-eabi
> new file mode 100644
> index 00000000000..ae08ea43ef7
> --- /dev/null
> +++ b/libgcc/config/arm/t-netbsd-eabi
> @@ -0,0 +1,18 @@
> +# This list is from t-elf, but with lots removed.
> +LIB1ASMFUNCS += _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX \
> +        _clzsi2 _clzdi2 _ctzsi2
> +
> +# Derived from t-bpabi
> +# Add the BPABI C functions.
> +LIB2ADD +=    $(srcdir)/config/arm/unaligned-funcs.c
> +
> +# Not using libgcc for EH.
> +LIB2ADDEH =
> +
> +# Add the BPABI names.
> +SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver
> +
> +# On ARM, specifying -fnon-call-exceptions will needlessly pull in
> +# the unwinder in simple programs which use 64-bit division.  Omitting
> +# the option is safe.
> +LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions
>
diff mbox series

Patch

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 3ee31c5993d..736b2163a24 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1161,10 +1161,33 @@  arm*-*-freebsd*)                # ARM FreeBSD EABI
 	with_tls=${with_tls:-gnu}
 	;;
 arm*-*-netbsdelf*)
-	tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h arm/aout.h ${tm_file} arm/netbsd-elf.h"
-	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
-	tmake_file="${tmake_file} arm/t-arm"
 	target_cpu_cname="strongarm"
+ 	tmake_file="${tmake_file} arm/t-arm"
+	tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h"
+	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
+	case ${target} in
+	arm*eb-*) tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1" ;;
+	esac
+	case ${target} in
+	arm*-*-netbsdelf-*eabi*)
+	    tm_file="$tm_file arm/bpabi.h arm/netbsd-elf.h arm/netbsd-eabi.h"
+	    tmake_file="$tmake_file arm/t-bpabi arm/t-netbsdeabi"
+	    ;;
+	*)
+	    tm_file="$tm_file arm/netbsd-elf.h"
+	    tmake_file="$tmake_file arm/t-netbsd"
+	    ;;
+	esac
+	tm_file="${tm_file} arm/aout.h arm/arm.h"
+	case ${target} in
+	arm*-*-netbsdelf-*eabihf*)
+	    tm_defines="${tm_defines} TARGET_DEFAULT_FLOAT_ABI=ARM_FLOAT_ABI_HARD"
+	    ;;
+	esac
+	case ${target} in
+	armv6*) target_cpu_cname="arm1176jzf-s";;
+	armv7*) target_cpu_cname="generic-armv7-a";;
+	esac
 	;;
 arm*-*-linux-*)			# ARM GNU/Linux with ELF
 	tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
diff --git a/gcc/config.host b/gcc/config.host
index 816a0f06cb7..5077c0ee33a 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -107,7 +107,7 @@  case ${host} in
 	;;
     esac
     ;;
-  arm*-*-freebsd* | arm*-*-linux* | arm*-*-fuchsia*)
+  arm*-*-freebsd* | arm*-*-netbsd* | arm*-*-linux* | arm*-*-fuchsia*)
     case ${target} in
       arm*-*-*)
 	host_extra_gcc_objs="driver-arm.o"
diff --git a/gcc/config/arm/netbsd-eabi.h b/gcc/config/arm/netbsd-eabi.h
new file mode 100644
index 00000000000..13bc274175d
--- /dev/null
+++ b/gcc/config/arm/netbsd-eabi.h
@@ -0,0 +1,97 @@ 
+/* Definitions of target machine for GNU compiler, NetBSD/arm ELF version.
+   Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Contributed by Wasabi Systems, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Run-time Target Specification.  */
+#undef MULTILIB_DEFAULTS
+#define MULTILIB_DEFAULTS { "mabi=aapcs-linux" }
+
+#define TARGET_LINKER_EABI_SUFFIX \
+    (TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_SOFT \
+     ? "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=hard:_eabihf;:_eabi}}}" \
+     : "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=soft:_eabi;:_eabihf}}}")
+#define TARGET_LINKER_BIG_EMULATION "armelfb_nbsd%(linker_eabi_suffix)"
+#define TARGET_LINKER_LITTLE_EMULATION "armelf_nbsd%(linker_eabi_suffix)"
+
+/* TARGET_BIG_ENDIAN_DEFAULT is set in
+   config.gcc for big endian configurations.  */
+#undef  TARGET_LINKER_EMULATION
+#if TARGET_BIG_ENDIAN_DEFAULT
+#define TARGET_LINKER_EMULATION TARGET_LINKER_BIG_EMULATION
+#else
+#define TARGET_LINKER_EMULATION TARGET_LINKER_LITTLE_EMULATION
+#endif
+
+#undef ARM_DEFAULT_ABI
+#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX
+
+#undef ARM_UNWIND_INFO
+#define ARM_UNWIND_INFO 0
+#undef DWARF2_UNWIND_INFO
+#define DWARF2_UNWIND_INFO 1
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS()		\
+  do						\
+    {						\
+      if (TARGET_AAPCS_BASED)			\
+	TARGET_BPABI_CPP_BUILTINS();		\
+      NETBSD_OS_CPP_BUILTINS_ELF();		\
+      if (DWARF2_UNWIND_INFO)			\
+	builtin_define ("__ARM_DWARF_EH__");	\
+    }						\
+  while (0)
+
+#undef SUBTARGET_CPP_SPEC
+#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
+
+/*
+ * Override AAPCS types to remain compatible the existing NetBSD types.
+ */
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef SIZE_TYPE
+#define SIZE_TYPE "long unsigned int"
+ 
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "long int"
+
+#undef SUBTARGET_EXTRA_ASM_SPEC
+#define SUBTARGET_EXTRA_ASM_SPEC	\
+  "-matpcs %{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu} %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
+
+#undef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS				\
+  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC }, \
+  { "linker_eabi_suffix",	TARGET_LINKER_EABI_SUFFIX }, \
+  { "linker_emulation",		TARGET_LINKER_EMULATION }, \
+  { "linker_big_emulation",	TARGET_LINKER_BIG_EMULATION }, \
+  { "linker_little_emulation",	TARGET_LINKER_LITTLE_EMULATION }, \
+  { "target_fix_v4bx_spec",	TARGET_FIX_V4BX_SPEC }, \
+  NETBSD_SUBTARGET_EXTRA_SPECS
+
+#define NETBSD_ENTRY_POINT "__start"
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+  "-X %{mbig-endian:-EB -m %(linker_big_emulation)} \
+   %{mlittle-endian:-EL -m %(linker_liitle_emulation)} \
+   %{!mbig-endian:%{!mlittle-endian:-m %(linker_emulation)}} \
+   %(target_fix_v4bx_spec) %(netbsd_link_spec)"
diff --git a/gcc/config/arm/netbsd-elf.h b/gcc/config/arm/netbsd-elf.h
index 5fcb543ed5f..0721ebd6a39 100644
--- a/gcc/config/arm/netbsd-elf.h
+++ b/gcc/config/arm/netbsd-elf.h
@@ -43,6 +43,7 @@ 
 #undef ARM_DEFAULT_ABI
 #define ARM_DEFAULT_ABI ARM_ABI_ATPCS
 
+#undef TARGET_OS_CPP_BUILTINS
 #define TARGET_OS_CPP_BUILTINS()	\
   do					\
     {					\
@@ -153,3 +154,12 @@  do									\
     (void) sysarch (0, &s);						\
   }									\
 while (0)
+
+/* Ensure that libgcc does not attempt to define __[CD]TOR_LIST__[] for APCS,
+ *    which belongs in crtbegin on NetBSD.  */
+#ifndef __ARM_EABI__
+#define CTOR_LISTS_DEFINED_EXTERNALLY
+#endif
+
+#undef FPUTYPE_DEFAULT
+#define FPUTYPE_DEFAULT "vfp"
diff --git a/gcc/config/netbsd-elf.h b/gcc/config/netbsd-elf.h
index e35758b9abc..ff722de0d53 100644
--- a/gcc/config/netbsd-elf.h
+++ b/gcc/config/netbsd-elf.h
@@ -1,4 +1,5 @@ 
 /* Common configuration file for NetBSD ELF targets.
+
    Copyright (C) 2002-2019 Free Software Foundation, Inc.
    Contributed by Wasabi Systems, Inc.
 
@@ -73,6 +74,9 @@  along with GCC; see the file COPYING3.  If not see
 
    Target-specific code must provide the %(netbsd_entry_point) spec.  */
 
+#define NETBSD_LINK_LD_ELF_SO_SPEC \
+  "%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}"
+
 #define NETBSD_LINK_SPEC_ELF \
   "%{assert*} %{R*} %{rpath*} \
    %{shared:-shared} \
@@ -87,6 +91,17 @@  along with GCC; see the file COPYING3.  If not see
        -dynamic-linker /usr/libexec/ld.elf_so} \
      %{static:-static}}"
 
+/* Provide the standard list of subtarget extra specs for NetBSD targets.  */
+#define NETBSD_SUBTARGET_EXTRA_SPECS \
+  { "netbsd_link_ld_elf_so",    NETBSD_LINK_LD_ELF_SO_SPEC }, \
+  { "netbsd_cpp_spec",          NETBSD_CPP_SPEC }, \
+  { "netbsd_link_spec",         NETBSD_LINK_SPEC_ELF }, \
+  { "netbsd_entry_point",       NETBSD_ENTRY_POINT }, \
+  { "netbsd_endfile_spec",      NETBSD_ENDFILE_SPEC },
+
+#undef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS   NETBSD_SUBTARGET_EXTRA_SPECS
+
 /* Use --as-needed -lgcc_s for eh support.  */
 #ifdef HAVE_LD_AS_NEEDED
 #define USE_LD_AS_NEEDED 1
diff --git a/libgcc/config.host b/libgcc/config.host
index 91abc84da03..ccf85bf900a 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -433,7 +433,15 @@  arm*-*-fuchsia*)
 	unwind_header=config/arm/unwind-arm.h
 	;;
 arm*-*-netbsdelf*)
-	tmake_file="$tmake_file arm/t-arm arm/t-netbsd t-slibgcc-gld-nover"
+	tmake_file="$tmake_file arm/t-arm"
+	case ${host} in
+	  arm*-*-netbsdelf-*eabi*)
+	    tmake_file="${tmake_file} arm/t-netbsd-eabi"
+	    ;;
+	  *)
+	    tmake_file="${tmake_file} arm/t-netbsd t-slibgcc-gld-nover"
+	    ;;
+	esac
 	;;
 arm*-*-linux*)			# ARM GNU/Linux with ELF
 	tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix t-crtfm"
diff --git a/libgcc/config/arm/t-netbsd b/libgcc/config/arm/t-netbsd
index 95358f931ba..eef6926c20d 100644
--- a/libgcc/config/arm/t-netbsd
+++ b/libgcc/config/arm/t-netbsd
@@ -1,7 +1,13 @@ 
+# This list is from t-elf, but with some things removed.
+LIB1ASMFUNCS += _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func \
+	_call_via_rX _interwork_call_via_rX \
+	_arm_fixunsdfsi _arm_fixunssfsi \
+	_arm_floatdidf _arm_floatdisf _arm_floatundidf _arm_floatundisf \
+	_lshrdi3 _ashrdi3 _ashldi3 \
+	_clzsi2 _clzdi2 _ctzsi2
+
 # Just for these, we omit the frame pointer since it makes such a big
 # difference.  It is then pointless adding debugging.
 HOST_LIBGCC2_CFLAGS += -fomit-frame-pointer
 
-LIBGCC2_DEBUG_CFLAGS = -g0
-
 LIB2ADD += $(srcdir)/floatunsidf.c $(srcdir)/floatunsisf.c
diff --git a/libgcc/config/arm/t-netbsd-eabi b/libgcc/config/arm/t-netbsd-eabi
new file mode 100644
index 00000000000..ae08ea43ef7
--- /dev/null
+++ b/libgcc/config/arm/t-netbsd-eabi
@@ -0,0 +1,18 @@ 
+# This list is from t-elf, but with lots removed.
+LIB1ASMFUNCS += _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX \
+        _clzsi2 _clzdi2 _ctzsi2
+
+# Derived from t-bpabi
+# Add the BPABI C functions.
+LIB2ADD +=    $(srcdir)/config/arm/unaligned-funcs.c
+
+# Not using libgcc for EH.
+LIB2ADDEH =
+
+# Add the BPABI names.
+SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver
+
+# On ARM, specifying -fnon-call-exceptions will needlessly pull in
+# the unwinder in simple programs which use 64-bit division.  Omitting
+# the option is safe.
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions