ARM Assembler Subroutine Pointer - pointers

I am trying to create code using ARM Assembler, and I need to call a subroutine stored in a register. As far as I know, the way to do this is:
Label:
% some code
LDR r3, =Label
BL r3
But when I try to compile that, the following error appears:
undefined reference to `r3'
collect2: ld returned 1 exit status
What am I doing wrong?

Related

Linking in julia fails

First time that happens to me. I do not know why it complains in such an easy step. I have seen the same ld error in another instances, but never on julia.
make
LINK usr/bin/julia
/usr/opt/centos/devtoolset-1.1/root/usr/bin/../libexec/gcc/x86_64-redhat-linux/4.7.2/ld: /usr/opt/centos/devtoolset-1.1/root/usr/bin/../lib /gcc/x86_64-redhat-linux/4.7.2/libstdc++_nonshared.a(system_error44.o): undefined reference to symbol '_ZTVSt14error_category##GLIBCXX_3.4.11'
/usr/opt/centos/devtoolset-1.1/root/usr/bin/../libexec/gcc/x86_64-redhat-linux/4.7.2/ld: note: '_ZTVSt14error_category##GLIBCXX_3.4.11' is defined in DSO /usr/lib64/libstdc++.so.6 so try adding it to the linker command line
/usr/lib64/libstdc++.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[1]: *** [/home/adrian/julia/usr/bin/julia] Error 1
make: *** [julia-ui-release] Error 2
How do I change the linkers direction for the one suggested in the output?

Linker/loader errors (unresolved function name symbols) in openr.c and writer.c

Compiled Arduino source and, at end of the build, got the unresolved symbols (function entry point names) for openr.c and writer.c
The invocation arguments used were consistent with the _open_r() and _write_r() function definitions, and they compile without errors.
Any suggestions on why this error came up, or even what openr.c and writer.c do are welcomed.
/home/digysol/arduino-1.8.0/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/fpu/libc.a(lib_a-openr.o): In function "_open_r": openr.c:(.text._open_r+0x10):
undefined reference to "_open"
/home/digysol/arduino-1.8.0/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/fpu/libc.a(lib_a-writer.o): In function "_write_r": writer.c:(.text._write_r+0x10):
undefined reference to "_write"
collect2: error: ld returned 1 exit status
undefined reference to "_open" I look at this and it automatically tells me it's a missing library.
The libc.a binary looks like it's trying to use it. So maybe libc.a is having trouble building with missing params, see a relevant question.

Procedure pointer returned from a function with nagfor

I try to use procedure pointers as a return of a function in Fortran. The following minimal code works with gfortran (tested with 4.8.1) but not with nagfor (NAG 6.0):
function foo() result(f_p)
implicit none
procedure(), pointer :: f_p
f_p => null()
end function foo
nagfor complains with:
Error: test.f90, line 5: Multiply defined symbol F_P
detected at ::#F_P
Error: test.f90, line 5: F_P is not a procedure name
detected at F_P#<end-of-statement>
Warning: test.f90, line 7: Result F_P of function FOO has not been assigned a value
[NAG Fortran Compiler pass 1 error termination, 2 errors, 1 warning]
Why is this?
Note: I'm very well aware of the danger for memory leaks when using procedure pointers in this way.
I work on the NAG Fortran Compiler and I can confirm that it does not yet implement this Fortran 2003 feature (functions returning procedure pointers).
Support for the feature is tentatively scheduled for the next (6.1) release.

MPI subroutines in Fortran

I have looked through all the posts on this topic I could find but they do not seem to solve my problem. I am thankful for any input/help/idea. So here it is:
I have my main program (main.f90):
program inv_main
use mod_communication
implicit none
include 'mpif.h'
...
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD,id,ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD,nproc,ierr)
...
call SENDRECEIVE(id, nproc, ierr, VVNP, VVN)
...
call MPI_FINALIZE(ierr)
end program inv_main
And here is the module that includes the subroutine (I am aware that allgather might be a better way to do the same but I could not figure it out yet for my 4D array):
Module mod_communication
implicit none
include 'mpif.h'
integer, dimension(MPI_STATUS_SIZE) :: STATUS ! MPI
CONTAINS
Subroutine SENDRECEIVE(id, nproc, ierr, INPUT, OUTPUT )
integer, intent (in) :: nproc, id, ierr
real (dp), intent(in) :: INPUT(n,m)
real (dp), intent(out) :: OUTPUT(n,m,nty,nty)
integer :: sndr
IF (id .eq. 0) THEN
OUTPUT(1:n,1:m,1,1)=INPUT
call MPI_RECV(INPUT,n*m,MPI_DOUBLE_PRECISION,MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,STATUS,ierr)
sndr=STATUS(MPI_SOURCE)
OUTPUT(1:n,1:m,int(sndr/nty)+1,sndr+1-nty*(int(sndr/nty))) = INPUT
END IF
IF (id .ne. 0) THEN
call MPI_SEND(INPUT,n*m,MPI_DOUBLE_PRECISION,0,id,MPI_COMM_WORLD,ierr)
ENDIF
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
call MPI_BCAST(OUTPUT,n*m*nty*nty,MPI_DOUBLE_PRECISION,0,MPI_COMM_WORLD,ierr)
end Subroutine
end Module mod_communication
This is the error message I got when compiling:
use mod_communication
2
Error: Symbol 'mpi_displacement_current' at (1) conflicts with symbol from module 'mod_communication', use-associated at (2)
mpif-mpi-io.h:71.36:
Included at mpif-config.h:65:
Included at mpif-common.h:70:
Included at mpif.h:59:
Included at main.f90:27:
integer MPI_MAX_DATAREP_STRING
1
main.f90:21.6:
use mod_communication
2
Error: Symbol 'mpi_max_datarep_string' at (1) conflicts with symbol from module 'mod_communication', use-associated at (2)
mpif-mpi-io.h:73.32:
Included at mpif-config.h:65:
Included at mpif-common.h:70:
Included at mpif.h:59:
Included at main.f90:27:
parameter (MPI_FILE_NULL=0)
These are just the first two errors, it keeps going like that... And I cannot find my mistake. Also, I have to use "include 'mpif.h'" and not "use mpi" because of the machine I am ultimately going to run it on. If I compile it with use mpi however on my own computer it gives me a different error, which is the following:
mod_MPI.f90:93.41:
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
1
Error: There is no specific subroutine for the generic 'mpi_barrier' at (1)
mod_MPI.f90:52.41:
Your main program probably gets (or rather tries to get) two copies of all the stuff in mpif.h. By include-ing it in the module you effectively make all its contents module things (variables, routines, parameters, what-nots). Then, in main you both use the module and, thereby, use-associate the module things, and try to include mpif.h and redeclare all those things again.
Do what #Jonathan Dursi suggests too.

Programming in Ada error in executing files

I just started programming in Ada and I have a problem in executing some files .adb.
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Trapeze(A:integer;B: Integer;C :Integer;D: Integer) is
procedure Traceligne(C:Character;X:Integer) is
begin
for I in 1 .. X loop
Put("C");
end loop;
end Traceligne;
H:Integer:=C;
Alpha:Integer:=D;
Decd:integer:=A;
Decg:integer:=B;
begin
for I in 1 .. H loop
Traceligne(' ',Decd);
Traceligne('*',Alpha);
Traceligne(' ',Decg);
Decd:=Decd-Integer(Decd*I/H);
Decg:=Decg-Integer(Decg*I/H);
Alpha:=Alpha+Integer(Decd*I/H)+Integer(Decg*I/H);
end loop;
get(x);
Trapeze(1,2,3,4)
end Trapeze;
i have this code error:
line 1: with: command not found.
I don't know the reason of this message .
PS: The question is simple for some programs my computer recognize the with Ada.Text_IOcommand and for some others it gives me the error mentioned before I don't know why.
In fact I found the real problem its in the compilation of the file it compiles but stops in gcc and doesn't continue to the gnatbind and gnatlink I hope you will have some suggestions.
The reason for the command not found message is that you're trying to execute the trapeze.adb file rather than an executable program built from it (trapeze or, on Windows, trapeze.exe).
The reason why GNAT hasn't built an executable program is that, in GNAT, a main program must be a parameterless procedure; presumably some of your test programs were parameterless, but this one isn't.
If you were hoping to be able to supply the parameters from the command line, as
$ ./trapeze 1 2 3 4
then you need to use Ada.Command_Line to retrieve them.

Resources