chenwj
chenwj

Reputation: 2069

Wildcard doesn't work in Mingw (Windows) GNU ld script

I am using the tool chain provided by GCC ARM Embedded. It seems ld (4.9-2015-q3-update) cannot handle wild card (*) with Windows path correctly.

For example, the code snippet below

.foo_v0 { obj\*(.s_foo_v0) }

won't find files under directory obj, and .foo_v0 gets nothing. Here is the report from mapfile:

.s_foo_v0       0x00008664       0x1c
 .s_foo_v0      0x00008664       0x1c obj\test\foo.o
                0x00008664                foo_v0

.foo_v0         0x00008680        0x0
 obj\test\*(.s_foo_v0)
                0x00008680                PROVIDE (__load_start_foo_v0, LOADADDR (.foo_v0))
                0x00008680                PROVIDE (__load_stop_foo_v0, (LOADADDR (.foo_v0) + SIZEOF (.foo_v0)))

Everything works fine on Cygwin, however, just need to use slash instead of backslash.

It's a known issue? Or is there a workaround?

Upvotes: 1

Views: 510

Answers (1)

chenwj
chenwj

Reputation: 2069

Doubling the backslash solves the problem.

.foo_v0 { obj\\*(.s_foo_v0) } 

Here is the report from mapfile,

.foo_v0         0x00008664       0x1c
 obj\\*(.s_foo_v0)
 .s_foo_v0      0x00008664       0x1c obj\test\foo.o
                0x00008664                foo_v0
                0x00008664                PROVIDE (__load_start_foo_v0, LOADADDR (.foo_v0))
                0x00008680                PROVIDE (__load_stop_foo_v0, (LOADADDR (.foo_v0) + SIZEOF (.foo_v0)))

It seems the first backslash escapes the latter one, so that the latter one won't escape the wildcard.

Upvotes: 1

Related Questions