Re: 32-bit powerpc and powerpc64 kernel relocation types when built via system-clang-8 and devel/powerpc64-binutils: a few R_PPC*_ADDR32 mixed in with the R_PPC*_RELATIVE

Mark Millard via freebsd-ppc <[email protected]>
Newsgroups gmane.os.freebsd.devel.ppc
Message-ID <[email protected]>

On 2019-Jun-2, at 13:25, Mark Millard <marklmi at yahoo.com> wrote:

> I'm not sure if getting a few R_PPC_ADDR32/R_PPC64_ADDR64
> in the kernel is expected or not.
> 
> This was a amd64 -> powerpc cross build from/for:
> 
> # uname -apKU
> FreeBSD FBSDFSSD 13.0-CURRENT FreeBSD 13.0-CURRENT #20 r347549M: Fri May 31 17:00:45 PDT 2019     markmi@FBSDFSSD:/usr/obj/amd64_clang/amd64.amd64/usr/src/amd64.amd64/sys/GENERIC-NODBG  amd64 amd64 1300025 1300025
> 
> system clang was used for the build but devel/powerpc64-binutils was used.
> 
> # readelf -asW /usr/obj/DESTDIRs/clang-powerpc-installkernel_altbinutils/boot/kernel/kernel | grep -v R_PPC_RELATIVE | less
> . . .
> Relocation section with addend (.rela.dyn):
> r_offset r_info   r_type              st_value st_name + r_addend
> 00da1744 00275101 R_PPC_ADDR32        00000000 uart_quicc_class + 0
> 
> Relocation section with addend (.rela.text):
> r_offset r_info   r_type              st_value st_name + r_addend
> 
> Relocation section with addend (.rela.data):
> r_offset r_info   r_type              st_value st_name + r_addend
> 
> Relocation section with addend (.rela.got):
> r_offset r_info   r_type              st_value st_name + r_addend
> 
> Relocation section with addend (.rela.got2):
> r_offset r_info   r_type              st_value st_name + r_addend
> 00e646d0 00117401 R_PPC_ADDR32        00000000 mfs_root_end + 0
> 00e646d4 002d7c01 R_PPC_ADDR32        00000000 mfs_root + 0
> 00e67c94 002b3a01 R_PPC_ADDR32        00000000 __stop_set_uart_fdt_class_set + 0
> 00e67c98 00210301 R_PPC_ADDR32        00000000 __start_set_uart_fdt_class_set + 0
> 
> . . .
> 
> 
> # readelf -asW /usr/obj/DESTDIRs/clang-powerpc64-installkernel_altbinutils/boot/kernel/kernel | grep -v R_PPC64_RELATIVE | less
> . . .
> Relocation section with addend (.rela.dyn):
> r_offset         r_info           r_type                   st_value         st_name + r_addend
> 000000000130c360 00002d2800000026 R_PPC64_ADDR64           0000000000000000 uart_quicc_class + 0
> 0000000001362008 0000143600000026 R_PPC64_ADDR64           0000000000000000 mfs_root_end + 0
> 0000000001362010 0000343300000026 R_PPC64_ADDR64           0000000000000000 mfs_root + 0
> 0000000001362018 000031a000000026 R_PPC64_ADDR64           0000000000000000 __stop_set_uart_fdt_class_set + 0
> 0000000001362020 000025fd00000026 R_PPC64_ADDR64           0000000000000000 __start_set_uart_fdt_class_set + 0
> 
> Relocation section with addend (.rela.text):
> r_offset         r_info           r_type                   st_value         st_name + r_addend
> 
> Relocation section with addend (.rela.data):
> r_offset         r_info           r_type                   st_value         st_name + r_addend
> 
> . . .
> 
> So it is always:
> 
> uart_quicc_class
> mfs_root_end
> mfs_root
> __stop_set_uart_fdt_class_set
> __start_set_uart_fdt_class_set
> 
> but the .rela.got2 vs. .rela.dyn status varies for all
> but uart_quicc_class in my context.
> 

Turns out that the gcc 4.2.1 related toolchain for 32-bit powerpc
produces:

# readelf -asW /usr/obj/DESTDIRs/gcc421-powerpc-installkernel/boot/kernel/kernel | grep -v R_PPC_RELATIVE | less
. . .
Relocation section with addend (.rela.dyn):
r_offset r_info   r_type              st_value st_name + r_addend

Relocation section with addend (.rela.text):
r_offset r_info   r_type              st_value st_name + r_addend

Relocation section with addend (.rela.data):
r_offset r_info   r_type              st_value st_name + r_addend

Relocation section with addend (.rela.got):
r_offset r_info   r_type              st_value st_name + r_addend

Relocation section with addend (.rela.got2):
r_offset r_info   r_type              st_value st_name + r_addend
00eaf92c 00117401 R_PPC_ADDR32        00000000 mfs_root_end + 0
00eaf930 002d7c01 R_PPC_ADDR32        00000000 mfs_root + 0
00eb28ec 00210401 R_PPC_ADDR32        00000000 __start_set_uart_fdt_class_set + 0
00eb28f0 002b3b01 R_PPC_ADDR32        00000000 __stop_set_uart_fdt_class_set + 0
00eb2940 00275101 R_PPC_ADDR32        00000000 uart_quicc_class + 0

Relocation section with addend (.rela.sdata):
r_offset r_info   r_type              st_value st_name + r_addend

. . .

So uart_quicc_class varies .rela.dyn vs. .rela.got2 compared to
system-clang with devel/powerpc64-binutils being used to target
32-bit powerpc. But there are still a count of 5 instances of
R_PPC_ADDR32.

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)

_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.