In Dwarf 3 (and Dwarf 2) attributes whose value are offsets into a section use the form DW_FORM_data4 whilst in Dwarf 4 and later they use the form DW_FORM_sec_offset.
This patch updates the places where such attributes are generated to use the appropriate form depending on the Dwarf version. The DIE entries affected have the following tags:
DW_AT_stmt_list, DW_AT_ranges, DW_AT_location, DW_AT_GNU_pubnames, DW_AT_GNU_pubtypes, DW_AT_GNU_addr_base, DW_AT_GNU_ranges_base
It also adds a hidden command line option "--dwarf-version=<uint>" to llc which allows the version of Dwarf to be generated to override what is specified in the metadata; this makes it possible to update existing tests to check the debugging information generated for both Dwarf 4 (the default) and Dwarf 3 using the same metadata.
I do apologize for the lateness of this comment, but rather than bringing this into addLabel I'd prefer we have a "getSectionOffset()" function that will return the proper form that can be used at the call site. Either that or make these function something like "addSectionOffset". Probably prefer the latter, but I'd want that patch to be more uniform across all of the additions.
Make sense? That possible in the time you have?