summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-26 13:43:32 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-26 13:43:32 +0000
commit90c3c302a9106d87793af0c02b7626e1df8db157 (patch)
tree42475b6f39c85b2b1ad062bdba00d0614f99b818
parented56837c5f266ade308f4306ffeb81a0d5eb05e0 (diff)
downloadpx4-nuttx-90c3c302a9106d87793af0c02b7626e1df8db157.tar.gz
px4-nuttx-90c3c302a9106d87793af0c02b7626e1df8db157.tar.bz2
px4-nuttx-90c3c302a9106d87793af0c02b7626e1df8db157.zip
function pointers in modules must have global scope
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1960 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/binfmt/libnxflat/libnxflat_bind.c9
-rw-r--r--nuttx/examples/nxflat/tests/mutex/mutex.c7
-rw-r--r--nuttx/examples/nxflat/tests/pthread/pthread.c7
-rw-r--r--nuttx/examples/nxflat/tests/signal/signal.c16
-rw-r--r--nuttx/examples/nxflat/tests/task/task.c7
5 files changed, 38 insertions, 8 deletions
diff --git a/nuttx/binfmt/libnxflat/libnxflat_bind.c b/nuttx/binfmt/libnxflat/libnxflat_bind.c
index 4e89a76ec..32442467a 100644
--- a/nuttx/binfmt/libnxflat/libnxflat_bind.c
+++ b/nuttx/binfmt/libnxflat/libnxflat_bind.c
@@ -235,6 +235,7 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
offset = ntohl(hdr->h_relocstart);
nrelocs = ntohs(hdr->h_reloccount);
+ bvdbg("offset: %08lx nrelocs: %d\n", (long)offset, nrelocs);
/* The value of the relocation list that we get from the header is a
* file offset. We will have to convert this to an offset into the
@@ -243,9 +244,13 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
*/
DEBUGASSERT(offset >= loadinfo->isize);
- DEBUGASSERT(offset + nrelocs * sizeof(struct nxflat_reloc_s) <= (loadinfo->isize + loadinfo->dsize));
+ DEBUGASSERT(offset + nrelocs * sizeof(struct nxflat_reloc_s)
+ <= (loadinfo->isize + loadinfo->dsize));
- relocs = (FAR struct nxflat_reloc_s*)(offset - loadinfo->isize + loadinfo->dspace->region);
+ relocs = (FAR struct nxflat_reloc_s*)
+ (offset - loadinfo->isize + loadinfo->dspace->region);
+ bvdbg("isize: %08lx dpsace: %p relocs: %p\n",
+ (long)loadinfo->isize, loadinfo->dspace->region, relocs);
/* Now, traverse the relocation list of and bind each GOT relocation. */
diff --git a/nuttx/examples/nxflat/tests/mutex/mutex.c b/nuttx/examples/nxflat/tests/mutex/mutex.c
index f161eb7fa..8e528da00 100644
--- a/nuttx/examples/nxflat/tests/mutex/mutex.c
+++ b/nuttx/examples/nxflat/tests/mutex/mutex.c
@@ -54,7 +54,12 @@ static unsigned long nerrors[2] = {0, 0};
* Private Functions
****************************************************************************/
-static void thread_func(void *parameter)
+/* NOTE: it is necessary for functions that are referred to by function pointers
+ * pointer to be declared with global scope (at least for ARM). Otherwise,
+ * a relocation type that is not supported by NXFLAT is generated by GCC.
+ */
+
+void thread_func(void *parameter)
{
int my_id = (int)parameter;
int my_ndx = my_id - 1;
diff --git a/nuttx/examples/nxflat/tests/pthread/pthread.c b/nuttx/examples/nxflat/tests/pthread/pthread.c
index 1cccfa055..6de82a46d 100644
--- a/nuttx/examples/nxflat/tests/pthread/pthread.c
+++ b/nuttx/examples/nxflat/tests/pthread/pthread.c
@@ -75,7 +75,12 @@ enum exit_values_e
* Private Functions
****************************************************************************/
-static void *child_start_routine(void *arg)
+/* NOTE: it is necessary for functions that are referred to by function pointers
+ * pointer to be declared with global scope (at least for ARM). Otherwise,
+ * a relocation type that is not supported by NXFLAT is generated by GCC.
+ */
+
+void *child_start_routine(void *arg)
{
printf("CHILD: started with arg=%d\n", (int)arg);
diff --git a/nuttx/examples/nxflat/tests/signal/signal.c b/nuttx/examples/nxflat/tests/signal/signal.c
index ff845ec10..ff1c58305 100644
--- a/nuttx/examples/nxflat/tests/signal/signal.c
+++ b/nuttx/examples/nxflat/tests/signal/signal.c
@@ -69,7 +69,12 @@ static int sigusr2_rcvd = 0;
* Name: sigusr1_sighandler
****************************************************************************/
-static void sigusr1_sighandler(int signo)
+/* NOTE: it is necessary for functions that are referred to by function pointers
+ * pointer to be declared with global scope (at least for ARM). Otherwise,
+ * a relocation type that is not supported by NXFLAT is generated by GCC.
+ */
+
+void sigusr1_sighandler(int signo)
{
printf("sigusr1_sighandler: Received SIGUSR1, signo=%d\n", signo);
sigusr1_rcvd = 1;
@@ -79,8 +84,13 @@ static void sigusr1_sighandler(int signo)
* Name: sigusr2_sigaction
***************************************************************************/
+/* NOTE: it is necessary for functions that are referred to by function pointers
+ * pointer to be declared with global scope (at least for ARM). Otherwise,
+ * a relocation type that is not supported by NXFLAT is generated by GCC.
+ */
+
#ifdef __USE_POSIX199309
-static void sigusr2_sigaction(int signo, siginfo_t *siginfo, void *arg)
+void sigusr2_sigaction(int signo, siginfo_t *siginfo, void *arg)
{
printf("sigusr2_sigaction: Received SIGUSR2, signo=%d siginfo=%p arg=%p\n",
signo, siginfo, arg);
@@ -107,7 +117,7 @@ static void sigusr2_sigaction(int signo, siginfo_t *siginfo, void *arg)
sigusr2_rcvd = 1;
}
#else
-static void sigusr2_sigaction(int signo)
+void sigusr2_sigaction(int signo)
{
printf("sigusr2_sigaction: Received SIGUSR2, signo=%d\n", signo);
sigusr2_rcvd = 1;
diff --git a/nuttx/examples/nxflat/tests/task/task.c b/nuttx/examples/nxflat/tests/task/task.c
index 039dff953..6083d68bd 100644
--- a/nuttx/examples/nxflat/tests/task/task.c
+++ b/nuttx/examples/nxflat/tests/task/task.c
@@ -58,7 +58,12 @@ static sem_t g_sem;
* Privite Functions
****************************************************************************/
-int child_task(int argc, char **argv)
+/* NOTE: it is necessary for functions that are referred to by function pointers
+ * pointer to be declared with global scope (at least for ARM). Otherwise,
+ * a relocation type that is not supported by NXFLAT is generated by GCC.
+ */
+
+ int child_task(int argc, char **argv)
{
printf("Child: execv was successful!\n");
printf("Child: argc=%d\n", argc);