Bug 28198 - ld: Support # as linker script comment marker
Summary: ld: Support # as linker script comment marker
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: 2.38
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-05 19:02 UTC by Fangrui Song
Modified: 2021-08-11 10:19 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed: 2021-08-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-08-05 19:02:03 UTC
Looks like # is supported in version scripts and the VERSION command in a linker script, but is unsupported outside of VERSION.

VERSION {
# meow meow
GLIBC_2.2.5 { global: __free_hook; local: *; };
GLIBC_2.2.6 { global: __nanosleep; local: *; };
}

ld.bfd a.o -T a.ver -shared

Moving the comment outside:

% ld.bfd a.o -T a.ver -shared -o a.so                                                                                                                                                                                                                                                      
ld.bfd:a.ver:1: ignoring invalid character `#' in expression
ld.bfd:a.ver:1: syntax error


gold and ld.lld support # outside of VERSION in a linker script.
Comment 1 cvs-commit@gcc.gnu.org 2021-08-11 10:17:45 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cc9faa98adc96788e6a560c685bbd8e69c856cb7

commit cc9faa98adc96788e6a560c685bbd8e69c856cb7
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Aug 11 18:16:35 2021 +0930

    PR28198, Support # as linker script comment marker
    
            PR 28198
            * ldlex.l: Combine rules for handling newline, whitespace and
            comments.  Extend # comment handling to all states.
Comment 2 Alan Modra 2021-08-11 10:19:46 UTC
Easy fix