<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.linux-xtensa.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Baruch</id>
	<title>Linux/Xtensa - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.linux-xtensa.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Baruch"/>
	<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Special:Contributions/Baruch"/>
	<updated>2026-05-05T02:24:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=ELF_Relocation_Notes&amp;diff=699</id>
		<title>ELF Relocation Notes</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=ELF_Relocation_Notes&amp;diff=699"/>
		<updated>2013-08-19T04:47:00Z</updated>

		<summary type="html">&lt;p&gt;Baruch: Split into two sections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; macros and data structures that are mentioned below refer to uClibc source code, unless otherwise stated.&lt;br /&gt;
&lt;br /&gt;
== Xtensa Global Offset Table ==&lt;br /&gt;
&lt;br /&gt;
The GOT has only one pointer entry. The link editor keeps in this GOT entry a pointer to the &amp;lt;tt&amp;gt;.dynamic&amp;lt;/tt&amp;gt; section. At run-time the dynamic linker sets the same entry to point to the _dl_linux_resolve() routine. This pointer is later replicated to the beginning of each PLT chunk using the &amp;lt;tt&amp;gt;R_XTENSA_RTLD&amp;lt;/tt&amp;gt; type 1 relocation (see below).&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;real&amp;quot; GOT is pointed at from and array of (offset, length) pairs (&amp;lt;tt&amp;gt;xtensa_got_location&amp;lt;/tt&amp;gt; data type) at the &amp;lt;tt&amp;gt;.got.loc&amp;lt;/tt&amp;gt; section. The offset and size of this array are kept in xtensa specific &amp;lt;tt&amp;gt;.dynamic&amp;lt;/tt&amp;gt; section tags named &amp;lt;tt&amp;gt;DT_XTENSA_GOT_LOC_OFF&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;DT_XTENSA_GOT_LOC_SZ&amp;lt;/tt&amp;gt;, respectively. This &amp;quot;real&amp;quot; GOT is part of &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section, and as such is flagged for read and execute only. However, xtensa specific macros (&amp;lt;tt&amp;gt;PERFORM_BOOTSTRAP_GOT&amp;lt;/tt&amp;gt; at start-up time, &amp;lt;tt&amp;gt;INIT_GOT&amp;lt;/tt&amp;gt; at run-time load [&amp;lt;tt&amp;gt;elf_machine_runtime_setup()&amp;lt;/tt&amp;gt; in glibc]) use &amp;lt;tt&amp;gt;_dl_mprotect()&amp;lt;/tt&amp;gt; to change the protection bits on the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; pages pointed from the &amp;lt;tt&amp;gt;.got.loc&amp;lt;/tt&amp;gt; section, and allow write access.&lt;br /&gt;
&lt;br /&gt;
Open questions:&lt;br /&gt;
&lt;br /&gt;
# The sections &amp;lt;tt&amp;gt;.got.loc&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.xt.lit&amp;lt;/tt&amp;gt; look identical, why are both needed?&lt;br /&gt;
# The &amp;lt;tt&amp;gt;.got.loc&amp;lt;/tt&amp;gt; section contains a short array of GOT locations at the beginning, and is mostly filled with zeros, why?&lt;br /&gt;
# Are &amp;lt;tt&amp;gt;.xt.lit&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.xt.prop&amp;lt;/tt&amp;gt; really needed at run-time?&lt;br /&gt;
&lt;br /&gt;
== Run-Time Relocations ==&lt;br /&gt;
&lt;br /&gt;
Xtensa run-time relocations as implemented in &amp;lt;tt&amp;gt;_dl_do_reloc()&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;tt&amp;gt;R_XTENSA_GLOB_DAT, R_XTENSA_JMP_SLOT&amp;lt;/tt&amp;gt; : Relocate to symbol address + addend. In terms of the Intel psABI the calculation is &#039;S + A&#039;.&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;tt&amp;gt;R_XTENSA_RTLD&amp;lt;/tt&amp;gt; : This includes two relocation types selected by the addend field. Type 1 inserts a pointer to the &amp;lt;tt&amp;gt;_dl_linux_resolve()&amp;lt;/tt&amp;gt; routine (taken by the dynamic linker from the first (and only) entry of the &amp;lt;tt&amp;gt;.got&amp;lt;/tt&amp;gt; section). Type 2 inserts a pointer to the per-module &#039;&amp;lt;tt&amp;gt;struct elf_resolve&amp;lt;/tt&amp;gt;&#039; data structure. According to the binutils &amp;lt;tt&amp;gt;elf_xtensa_finish_dynamic_sections()&amp;lt;/tt&amp;gt; routine, this relocation is emitted at the beginning of each PLT &amp;quot;chunk&amp;quot;. Each Chunk holds up to 254 PLT entries. The &amp;lt;tt&amp;gt;_dl_linux_resolve()&amp;lt;/tt&amp;gt; pointer, and the link map pointer (struct elf_resolve) are the first two parameters of the initial PLT routine (&amp;lt;tt&amp;gt;elf_xtensa_le_plt_entry[]&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;tt&amp;gt;R_XTENSA_RELATIVE&amp;lt;/tt&amp;gt; : Used to adjust internal pointers in the &amp;quot;real&amp;quot; GOT according to the current load address, mainly in shared libraries.&lt;/div&gt;</summary>
		<author><name>Baruch</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=ELF_Relocation_Notes&amp;diff=698</id>
		<title>ELF Relocation Notes</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=ELF_Relocation_Notes&amp;diff=698"/>
		<updated>2013-08-18T15:07:56Z</updated>

		<summary type="html">&lt;p&gt;Baruch: New page: &amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; macros and data structures that are mentioned below refer to uClibc source code, unless otherwise stated.  The Global Offset Table (GOT; resides in the &amp;lt;tt&amp;gt;.got&amp;lt;/tt&amp;gt; section) h...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; macros and data structures that are mentioned below refer to uClibc source code, unless otherwise stated.&lt;br /&gt;
&lt;br /&gt;
The Global Offset Table (GOT; resides in the &amp;lt;tt&amp;gt;.got&amp;lt;/tt&amp;gt; section) has only one pointer entry. The link editor keeps in this GOT entry a pointer to the &amp;lt;tt&amp;gt;.dynamic&amp;lt;/tt&amp;gt; section. At run-time the dynamic linker sets the same entry to point to the _dl_linux_resolve() routine. This pointer is later replicated to the beginning of each PLT chunk using the &amp;lt;tt&amp;gt;R_XTENSA_RTLD&amp;lt;/tt&amp;gt; type 1 relocation (see below).&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;real&amp;quot; GOT is pointed at from and array of (offset, length) pairs (&amp;lt;tt&amp;gt;xtensa_got_location&amp;lt;/tt&amp;gt; data type) at the &amp;lt;tt&amp;gt;.got.loc&amp;lt;/tt&amp;gt; section. The offset and size of this array are kept in xtensa specific &amp;lt;tt&amp;gt;.dynamic&amp;lt;/tt&amp;gt; section tags named &amp;lt;tt&amp;gt;DT_XTENSA_GOT_LOC_OFF&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;DT_XTENSA_GOT_LOC_SZ&amp;lt;/tt&amp;gt;, respectively. This &amp;quot;real&amp;quot; GOT is part of &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section, and as such is flagged for read and execute only. However, xtensa specific macros (&amp;lt;tt&amp;gt;PERFORM_BOOTSTRAP_GOT&amp;lt;/tt&amp;gt; at start-up time, &amp;lt;tt&amp;gt;INIT_GOT&amp;lt;/tt&amp;gt; at run-time load [&amp;lt;tt&amp;gt;elf_machine_runtime_setup()&amp;lt;/tt&amp;gt; in glibc]) use &amp;lt;tt&amp;gt;_dl_mprotect()&amp;lt;/tt&amp;gt; to change the protection bits on the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; pages pointed from the &amp;lt;tt&amp;gt;.got.loc&amp;lt;/tt&amp;gt; section, and allow write access.&lt;br /&gt;
&lt;br /&gt;
Open questions:&lt;br /&gt;
&lt;br /&gt;
# The sections &amp;lt;tt&amp;gt;.got.loc&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.xt.lit&amp;lt;/tt&amp;gt; look identical, why are both needed?&lt;br /&gt;
# The &amp;lt;tt&amp;gt;.got.loc&amp;lt;/tt&amp;gt; section contains a short array of GOT locations at the beginning, and is mostly filled with zeros, why?&lt;br /&gt;
# Are &amp;lt;tt&amp;gt;.xt.lit&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.xt.prop&amp;lt;/tt&amp;gt; really needed at run-time?&lt;br /&gt;
&lt;br /&gt;
Xtensa run-time relocations as implemented in &amp;lt;tt&amp;gt;_dl_do_reloc()&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;tt&amp;gt;R_XTENSA_GLOB_DAT, R_XTENSA_JMP_SLOT&amp;lt;/tt&amp;gt; : Relocate to symbol address + addend. In terms of the Intel psABI the calculation is &#039;S + A&#039;.&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;tt&amp;gt;R_XTENSA_RTLD&amp;lt;/tt&amp;gt; : This includes two relocation types selected by the addend field. Type 1 inserts a pointer to the &amp;lt;tt&amp;gt;_dl_linux_resolve()&amp;lt;/tt&amp;gt; routine (taken by the dynamic linker from the first (and only) entry of the &amp;lt;tt&amp;gt;.got&amp;lt;/tt&amp;gt; section). Type 2 inserts a pointer to the per-module &#039;&amp;lt;tt&amp;gt;struct elf_resolve&amp;lt;/tt&amp;gt;&#039; data structure. According to the binutils &amp;lt;tt&amp;gt;elf_xtensa_finish_dynamic_sections()&amp;lt;/tt&amp;gt; routine, this relocation is emitted at the beginning of each PLT &amp;quot;chunk&amp;quot;. Each Chunk holds up to 254 PLT entries. The &amp;lt;tt&amp;gt;_dl_linux_resolve()&amp;lt;/tt&amp;gt; pointer, and the link map pointer (struct elf_resolve) are the first two parameters of the initial PLT routine (&amp;lt;tt&amp;gt;elf_xtensa_le_plt_entry[]&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;tt&amp;gt;R_XTENSA_RELATIVE&amp;lt;/tt&amp;gt; : Used to adjust internal pointers in the &amp;quot;real&amp;quot; GOT according to the current load address, mainly in shared libraries.&lt;/div&gt;</summary>
		<author><name>Baruch</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Toolchain_and_Embedded_Distributions&amp;diff=697</id>
		<title>Toolchain and Embedded Distributions</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Toolchain_and_Embedded_Distributions&amp;diff=697"/>
		<updated>2013-07-17T09:29:46Z</updated>

		<summary type="html">&lt;p&gt;Baruch: Add a warning on running cross compilation on 64bit hosts&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== [[Toolchain Overlay File]] ==&lt;br /&gt;
&lt;br /&gt;
Because Xtensa is a configurable and extensible processor architecture that allows to define additional registers and instructions, the toolchain is the main software component that usually needs to be adapted for a specific Xtensa processor configuration. Tensilica provides a small set of configuration files in form of an &#039;&#039;overlay&#039;&#039; that replace the versions in the toolchain sources. The [[Toolchain Overlay File]] is a version of that &#039;&#039;overlay&#039;&#039; provided by Tensilica with a specific format required for crosstool-NG and buildroot. A script to convert the &#039;&#039;overlay&#039;&#039; provided by Tensilica can be found under [[Toolchain Overlay File]]&lt;br /&gt;
&lt;br /&gt;
== Start from scratch with FSF/OSS sources ==&lt;br /&gt;
&lt;br /&gt;
Creating a toolchain and bootable root file system starting from sources is certainly the most challenging approach. It usually requires additional patches and sometimes matching versions of sources. While support for Xtensa is integrated in most toolchain tools, they must be patches for a specific Xtensa processor configuration. The &#039;&#039;overlay&#039;&#039; metioned above includes a necessary set of configuration files together with information explaining the process to patch the toolchain sources.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; cross compilers running on 64bit hosts are known to produce broken code. For some more details see the [http://lists.linux-xtensa.org/pipermail/linux-xtensa/Week-of-Mon-20130715/001140.html explanation] of Chris Zankel.&lt;br /&gt;
&lt;br /&gt;
== [http://crosstool-ng.org/ crosstool-NG] &amp;lt;small&amp;gt;([[crosstool-NG|build instructions for Xtensa]])&amp;lt;/small&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
crosstool-NG (http://crosstool-ng.org/) provides a system to build a complete toolchain. It supports various C-libraries (Multilib, uClibc, glibc, and eglibc), but can also be used to build a &#039;bare&#039; toolchain. The current version does not yet support Xtensa as a target, but a development version can be retrieved from the local [http://git.linux-xtensa.org/ GIT] repositories. The process of patching the toolchain and other architecture specific software is fully automated using the [[Toolchain Overlay File]]. More information for building a toolchain for Xtensa using crosstool-NG can be found [[crosstool-NG|here]].&lt;br /&gt;
&lt;br /&gt;
== [http://www.buildroot.uclibc.org BuildRoot] &amp;lt;small&amp;gt;([[Buildroot|build instructions for Xtensa]])&amp;lt;/small&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a cross-compilation toolchain and root file system for your target Linux system. The Xtensa architecture is fully supported in the official tree, including support for specific processor configuration using the [[Toolchain Overlay File]]. For build instructions, see [[Buildroot]].&lt;/div&gt;</summary>
		<author><name>Baruch</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=DejaGnu&amp;diff=696</id>
		<title>DejaGnu</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=DejaGnu&amp;diff=696"/>
		<updated>2013-07-17T09:16:15Z</updated>

		<summary type="html">&lt;p&gt;Baruch: Typo fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;http://www.gnu.org/software/dejagnu/ is a framework for testing various other tools and programs.&lt;br /&gt;
&lt;br /&gt;
The following instructions are intended to run the test suite in a simulator or on a board running Linux. &lt;br /&gt;
&lt;br /&gt;
== Remote board using ssh ==&lt;br /&gt;
&lt;br /&gt;
== Remote board using telnet/FTP ==&lt;br /&gt;
&lt;br /&gt;
Although the preferred method to use dejagnu is over ssh, it might be necessary to use telnet and ftp, instead, if ssh is not supported or to slow on the particular target. Unfortunately, Dejagnu doesn&#039;t fully support telnet/ftp as a remote target out of the box, so it is necessary to patch the telnet.exp file. &lt;br /&gt;
The distribution running on that board needs to be configured to include support for an ftp and telnet daemon, and these services should be running.&lt;br /&gt;
&lt;br /&gt;
The telnet.exp file can usually be found under /usr/share/dejagnu/telnet.exp. http://linux-xtensa.org/pub/patches/dejagnu/dejagnu-telnet.patch.gz&lt;br /&gt;
&lt;br /&gt;
 cd /usr/share/dejagnu&lt;br /&gt;
 cp telnet.exp telnet.exp.orig&lt;br /&gt;
 gunzip -c &amp;lt;path-to&amp;gt;/dejagnu-telnet.patch.gz | patch -p0&lt;br /&gt;
&lt;br /&gt;
The next step is to create a board interface file for the target. In this example, we use the name &#039;lx60&#039;, but it can be any name.&lt;br /&gt;
&lt;br /&gt;
lx60.exp&lt;br /&gt;
 load_generic_config &amp;quot;unix&amp;quot;;                                                                                                                                    &lt;br /&gt;
 set_board_info hostname         &amp;quot;lx60&amp;quot;&lt;br /&gt;
 set_board_info compiler         &amp;quot;&amp;lt;path-to-compiler&amp;gt;/xtensa-linux-gcc&amp;quot;&lt;br /&gt;
 set_board_info connect          &amp;quot;telnet&amp;quot;&lt;br /&gt;
 set_board_info file_transfer    &amp;quot;ftp&amp;quot;&lt;br /&gt;
 set_board_info shell_prompt     &amp;quot;\\$ &amp;quot;&lt;br /&gt;
 set_board_info protocol         &amp;quot;telnet&amp;quot;&lt;br /&gt;
 set_board_info telnet_username  &amp;quot;test&amp;quot;&lt;br /&gt;
 set_board_info telnet_password  &amp;quot;test&amp;quot;&lt;br /&gt;
 set_board_info ftp_username     &amp;quot;test&amp;quot;&lt;br /&gt;
 set_board_info ftp_password     &amp;quot;test&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before we can run the testsuite, we need to tell it what board to use. Create the file site.exp under &amp;lt;path-to-libffi&amp;gt;/testsuite/site.exp with the following content:&lt;br /&gt;
 lappend boards_dir &amp;quot;&amp;lt;directory-that-includes-lx60.exp&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Finally, you can run the testsuite:&lt;br /&gt;
 export RUNTESTFLAGS=&amp;quot;--target_board=lx60&amp;quot;&lt;br /&gt;
 make check&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tensilica ISS Simulator ==&lt;br /&gt;
&lt;br /&gt;
The Tensilica ISS simulator is already supported by DejaGnu. The target name is xtensa-sim.&lt;/div&gt;</summary>
		<author><name>Baruch</name></author>
	</entry>
</feed>