Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

See if things build without these ldflags #142

Closed
wants to merge 1 commit into from
Closed

Conversation

alex
Copy link
Member

@alex alex commented Aug 23, 2019

No description provided.

@alex
Copy link
Member Author

alex commented Aug 23, 2019

So, clearly it doesn't... but now I understand a little bit more about why:

The problem is that https://github.com/torvalds/linux/blob/v5.2/scripts/mod/modpost.c#L697-L698 is never triggered.

I'm not sure what file this is run on, but I wonder if this isn't a .a vs. .o issue?

@alex
Copy link
Member Author

alex commented Aug 23, 2019

Tracing a bit more, that line of code follows after https://github.com/torvalds/linux/blob/v5.2/scripts/mod/modpost.c#L419-L450

Assuming I'm right that this is getting passed the .a file, it seems that that's our problem -- the .a won't have an ELF header here like a .o would.

I'm not sure what the best way to validate this hypothesis is, but I think fixing this is a pre-req for the mainline build system changes. Do we need to modify modpost in some way? Is there a way to convert our .a to a .o (ar -x && $CC *.o -o final.o)?

@alex
Copy link
Member Author

alex commented Aug 23, 2019

Ok, confirmed that if I take the .a, do:

$ mkdir z
$ cd z
$ ar -x ../target/x86_64-linux-kernel-module/debug/libhello_world.a
$ ld -relocatable *.o -o final.o

and then replace target/x86_64-linux-kernel-module/debug/libhello_world.a with z/final.o in helloworld-objs in the Makefile then everything builds correctly, without the EXTRA_LDFLAGS.

@geofft do you see a clear way to integrate this into our existing system, or should I just try to make this a part of the new build system in alex/linux#3?

geofft added a commit that referenced this pull request Sep 7, 2019
geofft added a commit that referenced this pull request Sep 7, 2019
@geofft
Copy link
Collaborator

geofft commented Sep 7, 2019

#175 looks like a clean way to do it - namely ld -r -o foo.o --whole-archive foo.a seems to have the same behavior as unpacking the archive and ld -r'ing its constituent files. The rest is Inspired by the approach you're taking at alex/linux#3. (You might want to take the --whole-archive trick though.)

@geofft
Copy link
Collaborator

geofft commented Sep 8, 2019

Now that #175 merged, can we close this?

@alex alex closed this Sep 8, 2019
@alex alex deleted the alex-patch-2 branch September 8, 2019 17:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants