Modifying htif.ld not affecting binaries

55 views
Skip to first unread message

Tim Liu

unread,
Mar 13, 2020, 5:18:25 PM3/13/20
to Chipyard
Hi there!

We're trying to boot from our own memory, and have changed the new linker script - htif.ld. I've changed the line:

. = 0x80000000

to

. = 0x3000000

so that our instructions start at 0x3000000. However, when I compile my hello_world.c file to a .dump, the addresses still all start at 0x80000000. Is there another file or linker script that specifies where the code is placed in memory?

Thanks!

Tim

Tim Liu

unread,
Mar 20, 2020, 12:00:07 AM3/20/20
to Chipyard
Hi there,

I tried this again in Chipyard 1-2 and am running into the same problem. Any updates on where else the address needs to be changed?

Thanks!

Tim

Colin Schmidt

unread,
Mar 20, 2020, 11:39:12 AM3/20/20
to chip...@googlegroups.com
How are you doing the compilation?

Are you sure you are passing the linker script to the compiler?

--
You received this message because you are subscribed to the Google Groups "Chipyard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chipyard+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chipyard/6cde4f71-16f6-4b2a-9cdf-706a2a10a88f%40googlegroups.com.

Tim Liu

unread,
Mar 20, 2020, 12:18:54 PM3/20/20
to Chipyard
Hi Colin, 

Thanks for the quick reply! And no, I am not sure I am passing the linker script to the compiler :'(

My compilation is just:

make hello_world.c

or:

make dumps hello_world.c

which is how I can see the addresses are wrong. Does something else have to be passed for htif.ld to be used?

Thanks!

Tim


On Friday, March 20, 2020 at 8:39:12 AM UTC-7, Colin Schmidt wrote:
How are you doing the compilation?

Are you sure you are passing the linker script to the compiler?

On Thu, Mar 19, 2020 at 9:00 PM Tim Liu <timl...@gmail.com> wrote:
Hi there,

I tried this again in Chipyard 1-2 and am running into the same problem. Any updates on where else the address needs to be changed?

Thanks!

Tim

On Friday, March 13, 2020 at 2:18:25 PM UTC-7, Tim Liu wrote:
Hi there!

We're trying to boot from our own memory, and have changed the new linker script - htif.ld. I've changed the line:

. = 0x80000000

to

. = 0x3000000

so that our instructions start at 0x3000000. However, when I compile my hello_world.c file to a .dump, the addresses still all start at 0x80000000. Is there another file or linker script that specifies where the code is placed in memory?

Thanks!

Tim

--
You received this message because you are subscribed to the Google Groups "Chipyard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chip...@googlegroups.com.

Tim Liu

unread,
Mar 20, 2020, 1:41:37 PM3/20/20
to Chipyard
Okay, I took a closer look at libgloss.mk. I've modified libgloss.mk to force a local build and set the target to riscv64-unknown-elf:

BUILD_LIBGLOSS=1
TARGET=riscv64-unknown-elf

and I'm seeing "Using local build" printed out and I can see that libgloss is:

libgloss/libgloss_htif.a ../toolchains/libgloss/util/htif_nano.specs htif.ld

So htif.ld is included in there. But running this make commands leaves the code at the original address. I've also tried adding 

-T htif.ld

to the command on the second line and the result is the same. Is there something else I'm missing to move the start address?

Thanks!

Tim

Baltazar Ortiz

unread,
May 25, 2020, 1:54:17 PM5/25/20
to Chipyard
Hi Tim,

Were you able to figure this out? I'm running into the same issue - opened an issue in the libgloss-htif repo in case that is a quicker turnaround as well.

Albert Ou

unread,
May 25, 2020, 2:50:03 PM5/25/20
to chip...@googlegroups.com
I had a fix on a separate branch, now pushed to master.

This changes the spec files to treat htif.ld as the default linker
script, which lets -T replace htif.ld entirely. Previously, since the
spec files used the -T option themselves, subsequent instances of -T
specified by the user merely appended to the existing script.

https://github.com/ucb-bar/libgloss-htif/commit/496a0b66b644241f1062e7c4ade87c55fa2fd286
> >>>> <https://groups.google.com/d/msgid/chipyard/6cde4f71-16f6-4b2a-9cdf-706a2a10a88f%40googlegroups.com?utm_medium=email&utm_source=footer>
> >>>> .
> >>>>
> >>>
>
> --
> You received this message because you are subscribed to the Google Groups "Chipyard" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chipyard+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/chipyard/f4284cdf-e3ad-48b6-a69f-e3ed0cd21396%40googlegroups.com.

--
Albert Ou

Albert Ou

unread,
May 25, 2020, 3:17:50 PM5/25/20
to chip...@googlegroups.com
Also, using a local version of htif.ld does not work if libgloss-htif
has already been installed to the toolchain location. Note that
directories specified with -L are added after the default linker search
path. Thus, ${RISCV}/riscv64-unknown-elf/lib/htif.ld takes precedence
over ./htif.ld in the current working directory.
--
Albert Ou

Baltazar Ortiz

unread,
May 25, 2020, 3:52:05 PM5/25/20
to Chipyard
Perfect, thank you for the fix and the clarification!
Reply all
Reply to author
Forward
0 new messages