After a previous question got answered: Adding a .S file to the linux kernel code I was able to add a .S file to the Linux kernel make files. However, my .S file includes several sections that replace functions that were written in C. I commented out these functions, and declared the replacement functions as globals, but when I try to link the kernel (using make) I get the following error:
arch/x86/kernel/vmlinux.lds:XXX: non constant or forward reference address expression for section .YYY
The original functions that I replaced were declared using:
__attribute__ ((unused, __section__("YYY"))) notrace
The asm sections are declared using:
.text
.globl YYY
I also tried adding:
.type YYY,@function
I probably missed some declaration somewhere, but I'm not sure where to look.
Any ideas?
If you want to place assembly functions into section YYY, rather than .text, you need to replace
.text
with
.section YYY,"ax"
This code:
.text
.globl YYY
tells the assembler that you are going to write things in the "text" section, and that "YYY" is a global within that section. Your .type adds that "YYY" is the name of a function. That's not what you want: you want the section to be named "YYY", not the function itself. To select a section with a specific name, use a .section directive (.text is just a shortcut for a .section which designates the "text" section).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With