public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Can't link assembly routines
@ 2024-03-13 12:05 Ken Woolridge
  2024-03-13 18:43 ` Steve Kargl
  0 siblings, 1 reply; 3+ messages in thread
From: Ken Woolridge @ 2024-03-13 12:05 UTC (permalink / raw)
  To: fortran


[-- Attachment #1.1: Type: text/plain, Size: 842 bytes --]

Hello,

I am trying to link gfortran routines which call assembly routines.  The linker cannot find these assembly routines although they have been
assembled using "as" and stored in a static library using "ar".

I have used the following options when assembling:

-c  --32  -a=list_file_name  -o obj_file_name

When I attempt to link my test program (FF.F90) which calls UPPER_CASE (an assembly routine) I get the following error:

C:/Program Files/GCC/bin/../lib/gcc/i686-pc-mingw32/13.2.0/../../../../i686-pc-mingw32/bin/ld.exe: FF.OBJ:FF.F90:(.text+0x10c): undefined reference to `upper_case_'
collect2.exe: error: ld returned 1 exit status
%LINK-E-LINKFAIL, linker failure - return code: 1

I have attached UPPER_CASE.ASM to this email for your perusal.

If you require more information, please ask.

Thank you,
Ken

[-- Attachment #2: UPPER_CASE.ASM --]
[-- Type: text/plain, Size: 5276 bytes --]

################################################################################
#                         U  P  P  E  R  _  C  A  S  E                         #
#                         ----------------------------                         #
# Subroutine to convert all lowercase characters in the passed Character       #
# variable to uppercase.                                                       #
#------------------------------------------------------------------------------#
# Calling format                                                               #
# ==============                                                               #
# CALL UPPER_CASE (string1)                                                    #
#                                                                              #
# Argument                                                                     #
# ========                                                                     #
# string1                                                                      #
#       [INOUT] A CHARACTER variable whose lowercase characters are to be      #
#       converted to uppercase.                                                #
#------------------------------------------------------------------------------#
# Interface                                                                    #
# =========                                                                    #
# SUBROUTINE UPPER_CASE (STRING1)                                              #
#  CHARACTER(*),INTENT(INOUT) :: STRING1                                       #
# END SUBROUTINE UPPER_CASE                                                    #
#------------------------------------------------------------------------------#
# Library File: SYS$LIBRARY:INTOOLSLIB.OLB                                     #
#------------------------------------------------------------------------------#
#   ***********************************************************************    #
#   *                           LIMITED RIGHTS                            *    #
#   *                                                                     *    #
#   *  This software is supplied without representation of warranty of    *    #
#   *  any kind.  The author therefore assumes no responsibility and      *    #
#   *  shall have no liability of any kind arising from the supply or     *    #
#   *  use of this software.                                              *    #
#   *                                                                     *    #
#   *  This software may be used only by the purchaser.  This software    *    #
#   *  or any other copies thereof may not be provided or otherwise made  *    #
#   *  available to any other person.  No title to and ownership of the   *    #
#   *  software is hereby transferred.                                    *    #
#   *                                                                     *    #
#   *  The information in this software is subject to change without      *    #
#   *  notice and should not be construed as a commitment by the author.  *    #
#   *                                                                     *    #
#   *  The information contained herein is proprietary to the author and  *    #
#   *  its use, disclosure, or duplication is restricted.                 *    #
#   ***********************************************************************    #
#------------------------------------------------------------------------------#
# D a t e      A u t h o r  Description of Modification                        #
# -----------  -----------  ---------------------------                        #
# 27-JUL-1993  K.Woolridge  Original.                                          #
################################################################################

         .NOLIST
         .INCLUDE  "C:\\SOURCE\\ASM\\INCLUDE\\ALPHABET_CHARS.INC"
         .LIST

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

         .GLOBAL   UPPER_CASE

UPPER_CASE:
         MOV       %EAX,4(%ESP)             # Get String address
         MOV       %EBX,8(%ESP)             # Get String Length
         MOV       %EDX,%EBX                # Save length
         MOV       %ECX,0

UC_01:                                      # Do
         MOV       %BL,(%EAX)               #    Next character
         CMP       %BL,PC_LO_A              #    Compare to "a"
         JL        UC_02                    #    Less than, don't change
         CMP       %BL,PC_LO_Z              #    Compare to "z"
         JG        UC_02                    #    Greater than, don't change
         SUB       %BL,0X20                 #    Convert to upper case
         MOV       (%EAX),%BL               #    Save converted character
UC_02:
         ADD       %EAX,1                   #    Increment pointer
         ADD       %ECX,1                   #    Increment counter
         CMP       %ECX,%EDX                #    Finished?
         JGE       RETURN                   #    Yes, exit
         JMP       UC_01                    # End do

RETURN:
         RET

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

* Re: Can't link assembly routines
  2024-03-13 12:05 Can't link assembly routines Ken Woolridge
@ 2024-03-13 18:43 ` Steve Kargl
  2024-03-14 23:47   ` rep.dot.nop
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Kargl @ 2024-03-13 18:43 UTC (permalink / raw)
  To: Ken Woolridge; +Cc: fortran

On Wed, Mar 13, 2024 at 12:05:16PM +0000, Ken Woolridge wrote:
> 
> When I attempt to link my test program (FF.F90) which calls UPPER_CASE (an assembly routine) I get the following error:
> 
> C:/Program Files/GCC/bin/../lib/gcc/i686-pc-mingw32/13.2.0/../../../../i686-pc-mingw32/bin/ld.exe: FF.OBJ:FF.F90:(.text+0x10c): undefined reference to `upper_case_'
> collect2.exe: error: ld returned 1 exit status

Well, does your archive contain a symbol name upper_case_?

-- 
Steve

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

* Re: Can't link assembly routines
  2024-03-13 18:43 ` Steve Kargl
@ 2024-03-14 23:47   ` rep.dot.nop
  0 siblings, 0 replies; 3+ messages in thread
From: rep.dot.nop @ 2024-03-14 23:47 UTC (permalink / raw)
  To: sgk, Steve Kargl, Ken Woolridge; +Cc: fortran

On 13 March 2024 19:43:27 CET, Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
>On Wed, Mar 13, 2024 at 12:05:16PM +0000, Ken Woolridge wrote:
>> 
>> When I attempt to link my test program (FF.F90) which calls UPPER_CASE (an assembly routine) I get the following error:
>> 
>> C:/Program Files/GCC/bin/../lib/gcc/i686-pc-mingw32/13.2.0/../../../../i686-pc-mingw32/bin/ld.exe: FF.OBJ:FF.F90:(.text+0x10c): undefined reference to `upper_case_'
>> collect2.exe: error: ld returned 1 exit status
>
>Well, does your archive contain a symbol name upper_case_?
>

See -funderscoring (sp)?
I think nowadays, you would use ISO_C_BINDING to describe the interface, though. I'm pretty sure that is documented somewhere..

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

end of thread, other threads:[~2024-03-14 23:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-13 12:05 Can't link assembly routines Ken Woolridge
2024-03-13 18:43 ` Steve Kargl
2024-03-14 23:47   ` rep.dot.nop

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).