Skip to content

Commit a186443

Browse files
committed
Get things working again, with LMA addresses specified.
Note that this temporary breaks 'after' statements. Need to work on ordering.
1 parent 6d17c7e commit a186443

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

ld.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@ func createLdScript(w *Wave) (io.Reader, error) {
1818
t := `
1919
ENTRY(_start)
2020
MEMORY {
21-
ram (RX) : ORIGIN = 0xFFFFFFFF80000000, LENGTH = 0x7FFFFFFF
21+
ram (RX) : ORIGIN = 0x80000000, LENGTH = 0x7FFFFFFF
22+
ram.bss (RW) : ORIGIN = 0x80000000, LENGTH = 0x7FFFFFFF
2223
}
2324
SECTIONS {
2425
_RomStart = 0x1000;
2526
_RomSize = _RomStart;
26-
..generatedStartEntry 0xFFFFFFFF80000400 : AT(_RomSize)
27+
..generatedStartEntry 0x80000400 : AT(_RomSize)
2728
{
2829
a.out (.text)
2930
a.out (.bss)
3031
a.out (.data)
3132
} > ram
3233
{{range .ObjectSegments -}}
33-
{{if not (eq .Positioning.Address 0)}}
34-
_RomSize = {{.Positioning.Address}} - 0xFFFFFFFF80000400 + _RomStart;
34+
{{if (gt .Positioning.Address 0x80000400)}}
35+
_RomSize = ({{.Positioning.Address}} - 0x80000400) + _RomStart;
3536
{{end}}
3637
_{{.Name}}SegmentRomStart = _RomSize;
3738
..{{.Name}}
@@ -70,10 +71,10 @@ SECTIONS {
7071
. = ALIGN(0x10);
7172
_{{.Name}}SegmentDataEnd = .;
7273
} > ram
73-
_RomSize += _{{.Name}}SegmentDataEnd - _{{.Name}}SegmentTextStart;
74+
_RomSize += (_{{.Name}}SegmentDataEnd - _{{.Name}}SegmentTextStart);
7475
_{{.Name}}SegmentRomEnd = _RomSize;
7576
76-
..{{.Name}}.bss ADDR(..{{.Name}}) + SIZEOF(..{{.Name}}) (NOLOAD) : AT(_RomSize)
77+
..{{.Name}}.bss ADDR(..{{.Name}}) + SIZEOF(..{{.Name}}) (NOLOAD) :
7778
{
7879
. = ALIGN(0x10);
7980
_{{.Name}}SegmentBssStart = .;
@@ -92,7 +93,7 @@ SECTIONS {
9293
. = ALIGN(0x10);
9394
_{{.Name}}SegmentBssEnd = .;
9495
_{{.Name}}SegmentEnd = .;
95-
} > ram
96+
} > ram.bss
9697
_{{.Name}}SegmentBssSize = _{{.Name}}SegmentBssEnd - _{{.Name}}SegmentBssStart;
9798
{{ end }}
9899
{{range .RawSegments -}}

spec.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func convertSegmentAst(s *SegmentAst) (*Segment, error) {
130130
seg.Name = statement.Value.String
131131
break
132132
case "address":
133-
seg.Positioning.Address = SignExtend(statement.Value.Int)
133+
seg.Positioning.Address = statement.Value.Int
134134
break
135135
case "after":
136136
if statement.Value.String != "" {
@@ -168,6 +168,7 @@ func convertSegmentAst(s *SegmentAst) (*Segment, error) {
168168
}
169169
break
170170
case "number":
171+
seg.Positioning.Address = statement.Value.Int * 0x1000000
171172
// Don't do anything, as we don't really care here.
172173
// All that matters for code is the rom address.
173174
break
@@ -217,7 +218,7 @@ func convertWaveAst(s *WaveAst, segments map[string]*Segment) (*Wave, error) {
217218
func (w *Wave) updateWithConstants() {
218219
for _, seg := range w.ObjectSegments {
219220
if seg.Flags.Boot && seg.Positioning.Address == 0 {
220-
seg.Positioning.Address = SignExtend(0x80000450)
221+
seg.Positioning.Address = 0x80000450
221222
}
222223
}
223224
}
@@ -333,7 +334,7 @@ func (w *Wave) correctOrdering() {
333334
// TODO(trhodeos): Make this actually correct. This just places any
334335
// explicitly addressed segments before any 'after.*' segments. If
335336
// 'after' segments depend on other 'after' segments, this'll break.
336-
l := list.New()
337+
/*l := list.New()
337338
for _, seg := range w.ObjectSegments {
338339
if seg.Positioning.Address != 0 {
339340
l.PushBack(seg)
@@ -356,6 +357,7 @@ func (w *Wave) correctOrdering() {
356357
newSegments = append(newSegments, original)
357358
}
358359
w.ObjectSegments = newSegments
360+
*/
359361
}
360362

361363
func (w *Wave) GetBootSegment() *Segment {

0 commit comments

Comments
 (0)