Skip to content

Commit 1622c1e

Browse files
committed
scripts: llext: support relocatable link bypass
When CONFIG_LLEXT_TYPE_ELF_RELOCATABLE is active, bypass appending static address flags (-Ttext, --section-start, -Tdata) in the linker helper script. This keeps section base addresses at 0. Also adjust the offset calculator to avoid integer parsing errors when all section addresses are set to 0. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 331b378 commit 1622c1e

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

scripts/llext_link_helper.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def main():
7777

7878
command = [args.command]
7979

80+
is_relocatable = '-r' in args.params
81+
8082
executable = []
8183
writable = []
8284
readonly = []
@@ -111,7 +113,8 @@ def main():
111113
text_found = True
112114
text_addr = max_alignment(text_addr, 0x1000, s_alignment)
113115
text_size = s_size
114-
command.append(f'-Wl,-Ttext=0x{text_addr:x}')
116+
if not is_relocatable:
117+
command.append(f'-Wl,-Ttext=0x{text_addr:x}')
115118
else:
116119
executable.append(section)
117120

@@ -164,7 +167,8 @@ def main():
164167

165168
dram_addr = align_up(dram_addr, s_alignment)
166169

167-
command.append(f'-Wl,--section-start={s_name}=0x{dram_addr:x}')
170+
if not is_relocatable:
171+
command.append(f'-Wl,--section-start={s_name}=0x{dram_addr:x}')
168172

169173
dram_addr += section.header['sh_size']
170174

@@ -177,7 +181,8 @@ def main():
177181

178182
dram_addr = align_up(dram_addr, s_alignment)
179183

180-
command.append(f'-Wl,--section-start={s_name}=0x{dram_addr:x}')
184+
if not is_relocatable:
185+
command.append(f'-Wl,--section-start={s_name}=0x{dram_addr:x}')
181186

182187
dram_addr += section.header['sh_size']
183188

@@ -189,7 +194,8 @@ def main():
189194

190195
start_addr = align_up(start_addr, s_alignment)
191196

192-
command.append(f'-Wl,--section-start={s_name}=0x{start_addr:x}')
197+
if not is_relocatable:
198+
command.append(f'-Wl,--section-start={s_name}=0x{start_addr:x}')
193199

194200
start_addr += section.header['sh_size']
195201

@@ -201,10 +207,11 @@ def main():
201207

202208
start_addr = align_up(start_addr, s_alignment)
203209

204-
if s_name == '.data':
205-
command.append(f'-Wl,-Tdata=0x{start_addr:x}')
206-
else:
207-
command.append(f'-Wl,--section-start={s_name}=0x{start_addr:x}')
210+
if not is_relocatable:
211+
if s_name == '.data':
212+
command.append(f'-Wl,-Tdata=0x{start_addr:x}')
213+
else:
214+
command.append(f'-Wl,--section-start={s_name}=0x{start_addr:x}')
208215

209216
start_addr += section.header['sh_size']
210217

scripts/llext_offset_calc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def get_elf_size(elf_name):
4747
if section.header['sh_addr'] + section.header['sh_size'] > end:
4848
end = section.header['sh_addr'] + section.header['sh_size']
4949

50+
if start == 0xffffffff:
51+
return 0
52+
5053
size = end - start
5154

5255
return size

0 commit comments

Comments
 (0)