Skip to contentSkip to conversation

openrisc: various fixes

PATCH New Stafford Horne 1 participant 7 messages Feb 6, 2017 – Mar 15, 2017

lore
Share & tools
lore
#0 lore raw

cover openrisc: various fixes

Hello,

These are a few patches that have collected in the openrisc newlib repository on github over the last year. Most issues were found when running the gdb test suite as I worked on getting that ready for upstream.

I am working with Stefan Wallentowitz who has sent openrisc patches in the past.

Olof Kindgren (1):
or1k: Make open reentrant

Stafford Horne (2):
libgloss: or1k: If available call the init for init_array
libgloss: Remove duplicate definition of environ

 libgloss/or1k/crt0.S     | 6 ++++++
 libgloss/or1k/syscalls.c | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/3 or1k: Make open reentrant

From: Olof Kindgren <[email protected]>

or1k uses reentrant calls by default, but there was no open_r defined which caused failure in C++/C code such as:

int main() { std::cout << "test\n"; return 0; }

or

int main() {open(".", 0);}

---
 libgloss/or1k/syscalls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libgloss/or1k/syscalls.c +1 -1
index 690d21a..3e2ad22 100644
@@ -124,7 +124,7 @@ _lseek_r(struct _reent *reent, int file, _off_t ptr, int dir)
 }
 
 int
-_open(struct _reent *reent, char *file, int flags, int mode)
+_open_r(struct _reent *reent, const char *file, int flags, int mode)
 {
 	reent->_errno = ENOSYS;
 	return -1;
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/3 libgloss: or1k: If available call the init for init_array

In reply to Stafford Horne

There was an issue revealed in gdb testing where C++ virtual tables were not getting properly initialized. This seems to be due to the c++ global constructors moving from ctors to init_array.

This fix makes sure we call the proper method for initializing the constructors in all places.

---
 libgloss/or1k/crt0.S | 6 ++++++
 1 file changed, 6 insertions(+)
libgloss/or1k/crt0.S +6 -0
index 84adba1..03d7323 100644
@@ -36,6 +36,7 @@
       the obvious things..                                                    */
 /* -------------------------------------------------------------------------- */
 
+#include "newlib.h"
 #include "include/or1k-asm.h"
 #include "include/or1k-sprs.h"
 
@@ -96,6 +97,11 @@ _or1k_exception_stack_size:	.word EXCEPTION_STACK_SIZE
                                                                               */
 /* -------------------------------------------------------------------------- */
 
+#ifdef HAVE_INITFINI_ARRAY
+#define _init	__libc_init_array
+#define _fini	__libc_fini_array
+#endif
+
 #define GPR_BUF_OFFSET(x) (x << 2)
 
 #ifndef __OR1K_MULTICORE__
Signature · 1 line
2.9.3
#3 lore raw

PATCH 3/3 libgloss: Remove duplicate definition of environ

In reply to Stafford Horne

Environ is defined in libgloss and libc:
- libgloss/or1k/syscalls.c
- libc/stdlib/environ.c

When linking we sometimes get errors:
or1k-elf-g++ test.o -mnewlib -mboard=or1ksim -lm -o test /opt/shorne/software/or1k/lib/gcc/or1k-elf/5.3.0/../../../../or1k-elf/lib/libor1k.a(syscalls.o):(.data+0x0):
multiple definition of `environ' /opt/shorne/software/or1k/lib/gcc/or1k-elf/5.3.0/../../../../or1k-elf/lib/libc.a(lib_a-environ.o):(.data+0x0):
first defined here
collect2: error: ld returned 1 exit status

This doesnt happen after the fix. Basic things build fine too.

---
 libgloss/or1k/syscalls.c | 3 ---
 1 file changed, 3 deletions(-)
libgloss/or1k/syscalls.c +0 -3
index 3e2ad22..92bff49 100644
@@ -56,9 +56,6 @@ _close_r(struct _reent *reent, int fildes)
 	return -1;
 }
 
-char *__env[1] = { 0 };
-char **environ = __env;
-
 int
 _execve_r(struct _reent *reent, const char *name, char * const *argv,
 		char * const *env)
Signature · 1 line
2.9.3
#4 lore raw

cover openrisc: various fixes

In reply to Stafford Horne

Hello,

Any comment on this series?

Quoted 24 lines · Stafford Horne

Hello,

These are a few patches that have collected in the openrisc newlib repository on github over the last year. Most issues were found when running the gdb test suite as I worked on getting that ready for upstream.

I am working with Stefan Wallentowitz who has sent openrisc patches in the past.

Olof Kindgren (1):
or1k: Make open reentrant

Stafford Horne (2):
libgloss: or1k: If available call the init for init_array
libgloss: Remove duplicate definition of environ

 libgloss/or1k/crt0.S     | 6 ++++++
 libgloss/or1k/syscalls.c | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

--
2.9.3

#5 lore raw

cover openrisc: various fixes

Hello.

Sorry my mistake. Corinna replied that this patch series was pushed. I didn't get that mail.

https://sourceware.org/ml/newlib/2017/msg00139.html

Quoted 30 lines · Stafford Horne

Hello,

Any comment on this series?

Quoted 24 lines · Stafford Horne

Hello,

These are a few patches that have collected in the openrisc newlib repository on github over the last year. Most issues were found when running the gdb test suite as I worked on getting that ready for upstream.

I am working with Stefan Wallentowitz who has sent openrisc patches in the past.

Olof Kindgren (1):
or1k: Make open reentrant

Stafford Horne (2):
libgloss: or1k: If available call the init for init_array
libgloss: Remove duplicate definition of environ

 libgloss/or1k/crt0.S     | 6 ++++++
 libgloss/or1k/syscalls.c | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

--
2.9.3

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.librecores.org/pipermail/openrisc/attachments/20170316/147bc975/attachment.html>

#6 lore raw

cover openrisc: various fixes

In reply to Stafford Horne
Quoted 3 lines · Stafford Horne

Hello,

Any comment on this series?

Sorry, my mistake Corinna replied on this but I missed it.

https://sourceware.org/ml/newlib/2017/msg00139.html

Quoted 25 lines · Stafford Horne
Quoted 24 lines

Hello,

These are a few patches that have collected in the openrisc newlib repository on github over the last year. Most issues were found when running the gdb test suite as I worked on getting that ready for upstream.

I am working with Stefan Wallentowitz who has sent openrisc patches in the past.

Olof Kindgren (1):
or1k: Make open reentrant

Stafford Horne (2):
libgloss: or1k: If available call the init for init_array
libgloss: Remove duplicate definition of environ

 libgloss/or1k/crt0.S     | 6 ++++++
 libgloss/or1k/syscalls.c | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

--
2.9.3