b94d1a2a21238049e0ba0f40f0278d936d9cdda5
[fw/altos] / debian / patches / linker-n+openocd.diff
1 diff --git a/ao-tools/ao-elftohex/ao-elftohex.c b/ao-tools/ao-elftohex/ao-elftohex.c
2 index 265908c5..f3ab0c38 100644
3 --- a/ao-tools/ao-elftohex/ao-elftohex.c
4 +++ b/ao-tools/ao-elftohex/ao-elftohex.c
5 @@ -19,6 +19,7 @@
6  #include <getopt.h>
7  #include <stdlib.h>
8  #include <string.h>
9 +#include <unistd.h>
10  #include "ao-hex.h"
11  #include "ao-elf.h"
12  #include "ao-verbose.h"
13 diff --git a/ao-tools/ao-flash/ao-flash-lpc b/ao-tools/ao-flash/ao-flash-lpc
14 index 7ac5b523..9e1d1cdb 100755
15 --- a/ao-tools/ao-flash/ao-flash-lpc
16 +++ b/ao-tools/ao-flash/ao-flash-lpc
17 @@ -8,9 +8,9 @@ esac
18  cmds=/tmp/flash$$
19  trap "rm $cmds" 0 1 15
20  file="$1"
21 -echo "program $file verify reset" > $cmds
22 +echo "program $file reset" > $cmds
23  openocd \
24         -f interface/stlink-v2.cfg \
25 -       -f target/lpc11u14.cfg \
26 +       -f target/lpc11xx.cfg \
27         -f $cmds \
28         -c shutdown
29 diff --git a/ao-tools/lib/ao-elf.c b/ao-tools/lib/ao-elf.c
30 index c44102f8..cc127b62 100644
31 --- a/ao-tools/lib/ao-elf.c
32 +++ b/ao-tools/lib/ao-elf.c
33 @@ -186,6 +186,7 @@ load_write(struct ao_hex_image *from, uint32_t address, uint32_t length, void *d
34         return new;
35  }
36  
37 +#define DBG 0
38  /*
39   * Construct a large in-memory block for all
40   * of the loaded sections of the program
41 @@ -202,7 +203,7 @@ get_load(Elf *e)
42         GElf_Phdr       phdr;
43         GElf_Addr       sh_paddr;
44         struct ao_hex_image     *load = NULL;
45 -#if 0
46 +#if DBG
47         char            *section_name;
48  #endif
49         size_t          nshdr;
50 @@ -231,7 +232,7 @@ get_load(Elf *e)
51  
52                 /* Get the associated file section */
53  
54 -#if 0
55 +#if DBG
56                 fprintf (stderr, "offset %08x vaddr %08x paddr %08x filesz %08x memsz %08x\n",
57                          (uint32_t) phdr.p_offset,
58                          (uint32_t) phdr.p_vaddr,
59 @@ -252,18 +253,16 @@ get_load(Elf *e)
60                                 abort();
61                         }
62  
63 -#if 0
64 +#if DBG
65                         section_name = elf_strptr(e, shstrndx, shdr.sh_name);
66  #endif
67  
68 -                       if (phdr.p_offset <= shdr.sh_offset && shdr.sh_offset < phdr.p_offset + phdr.p_filesz) {
69 -
70 -                               if (shdr.sh_size == 0)
71 -                                       continue;
72 -
73 +                       if (shdr.sh_size != 0 && shdr.sh_type != SHT_NOBITS && (shdr.sh_flags & SHF_ALLOC) &&
74 +                           phdr.p_offset <= shdr.sh_offset && shdr.sh_offset < phdr.p_offset + phdr.p_filesz)
75 +                       {
76                                 sh_paddr = phdr.p_paddr + shdr.sh_offset - phdr.p_offset;
77  
78 -#if 0
79 +#if DBG
80                                 fprintf (stderr, "\tsize %08x rom %08x exec %08x %s\n",
81                                          (uint32_t) shdr.sh_size,
82                                          (uint32_t) sh_paddr,
83 diff --git a/src/lpc/Makefile.defs b/src/lpc/Makefile.defs
84 index b6d739c2..5bb8133d 100644
85 --- a/src/lpc/Makefile.defs
86 +++ b/src/lpc/Makefile.defs
87 @@ -5,7 +5,7 @@ endif
88  include $(TOPDIR)/lpc/Makefile-lpc.defs
89  include $(TOPDIR)/Makedefs
90  
91 -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/lpc -Wl,-Taltos.ld
92 +LDFLAGS=$(CFLAGS) -L$(TOPDIR)/lpc -Wl,-Taltos.ld -n
93  
94  ao_serial_lpc.h: $(TOPDIR)/lpc/baud_rate ao_pins.h
95         nickle $(TOPDIR)/lpc/baud_rate `awk '/AO_LPC_CLKOUT/{print $$3}' ao_pins.h` > $@
96 diff --git a/src/stmf0/Makefile.defs b/src/stmf0/Makefile.defs
97 index a1d93eb5..3da42874 100644
98 --- a/src/stmf0/Makefile.defs
99 +++ b/src/stmf0/Makefile.defs
100 @@ -4,6 +4,6 @@ endif
101  
102  include $(TOPDIR)/stmf0/Makefile-stmf0.defs
103  
104 -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Taltos.ld
105 +LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Taltos.ld -n
106  
107  .DEFAULT_GOAL=all
108 diff --git a/src/telegps-v0.3/Makefile b/src/telegps-v0.3/Makefile
109 index 1eaf7c47..834609d9 100644
110 --- a/src/telegps-v0.3/Makefile
111 +++ b/src/telegps-v0.3/Makefile
112 @@ -67,8 +67,6 @@ OBJ=$(SRC:.c=.o)
113  
114  all: $(PROG) $(HEX)
115  
116 -LDFLAGS=-L../lpc -Wl,-Taltos.ld
117 -
118  $(PROG): Makefile $(OBJ) altos.ld
119         $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
120  
121 diff --git a/src/telegps-v1.0/Makefile b/src/telegps-v1.0/Makefile
122 index bd13cfe7..76dc0371 100644
123 --- a/src/telegps-v1.0/Makefile
124 +++ b/src/telegps-v1.0/Makefile
125 @@ -70,8 +70,6 @@ OBJ=$(SRC:.c=.o)
126  
127  all: $(PROG) $(HEX)
128  
129 -LDFLAGS=-L../lpc -Wl,-Taltos.ld
130 -
131  $(PROG): Makefile $(OBJ) altos.ld
132         $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
133